Skip to content

Issue with -F= #32

@phpandrew

Description

@phpandrew

curl -X POST "https://api.squarespace.com/1.0/commerce/products/123/images" -i -H "Authorization: Bearer YOUR_API_KEY_OR_OAUTH_TOKEN" -H "User-Agent: YOUR_CUSTOM_APP_DESCRIPTION" -F file=@steak.png

Results in:

// Generated by curl-to-PHP: http://incarnate.github.io/curl-to-php/
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://api.squarespace.com/1.0/commerce/products/123/images');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'file' => '@' .realpath('steak.png'));

$headers = array();
$headers[] = 'Authorization: Bearer YOUR_API_KEY_OR_OAUTH_TOKEN';
$headers[] = 'User-Agent: YOUR_CUSTOM_APP_DESCRIPTION';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close($ch);

It should be:
curl_setopt($ch, CURLOPT_POSTFIELDS, array('file' => '@' .realpath('steak.png')));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions