Square Connect API – image upload – Response 100

I am using the following example and keep getting an response from the server of 100. The image does not update in Square at all.

Found from:
Square Connect API – image upload – Empty Reply From Server code 52 error

Read More

https://gist.github.com/tdeck/7118c7128a4a2b653d11

(blanked out locationa and item id)
POST to https://connect.squareup.com/v1/XXXXXX/items/XXXXXXX/image with status 100

I am using your example exactly Here are the variables I am sending to it: This is coming from a wordpress install.

uploadItemImage( 
'https://connect.squareup.com/v1/XXXXX/items/XXXXX/image', 
'XXXXXXXXXXX', 
'wp-content/uploads/2015/04/imagename.jpg' 
) 

);

Here is the curl output I get with the jpeg added in Item ID and Token are obscured. The image getting uploaded is quite a bit larger then 209bytes. But that is all that is getting sent.

[url] => https://connect.squareup.com/v1/me/items/ITEMID/image
[content_type] => 
[http_code] => 100
[header_size] => 71
[request_size] => 288
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 61.486827
[namelookup_time] => 0.114398
[connect_time] => 0.225888
[pretransfer_time] => 1.347979
[size_upload] => 209
[size_download] => 0
[speed_download] => 0
[speed_upload] => 3
[download_content_length] => -1
[upload_content_length] => 209
[starttransfer_time] => 1.396955
[redirect_time] => 0
[redirect_url] => 
[primary_ip] => 74.122.189.136
[certinfo] => Array
    (
    )

[primary_port] => 443
[local_ip] => 192.168.1.117
[local_port] => 60968
[request_header] => POST /v1/me/items/ITEMID/image HTTP/1.1
Host: connect.squareup.com
Accept: */*
Authorization: Bearer TOKEN
Content-Length: 209
Expect: 100-continue
Content-Type: multipart/form-data; boundary=------------------------754042306466c83e

Related posts

1 comment

  1. It looks like a mime-type check was added to the API since I wrote that example code. In order to add the content type header to the image part of the multipart request, you need to change

    curl_setopt($ch, CURLOPT_POSTFIELDS, ['image_data' => "@$image_file"]);
    

    to

    curl_setopt($ch, CURLOPT_POSTFIELDS, ['image_data' => "@$image_file;type=image/jpeg"]);
    

    After trying that, it worked for me. I’ll update my gist to reflect this.

Comments are closed.