I've spent days trying to successfully upload images with the image_upload endpoint using the Square Connect v1 API. The API docs are here
Currently, I'm getting the following response after making the POST.
{"type":"bad_request","message":"Could not create image"}
I'm using the node-request library as such:
const formData = {
image_data: {
value: BASE64IMAGE,
options: {
'Content-Disposition': 'form-data',
filename: 'hat.jpg',
'Content-Type': 'image/jpeg',
},
},
};
request.post(
{
method: 'POST',
url: `https://connect.squareup.com/v1/${location}/items/${item_id}/image`,
headers: {
Authorization: `Bearer ${access_token}`,
'Content-Type': 'multipart/form-data; boundary=BOUNDARY',
Accept: 'application/json',
},
formData,
},
(err, httpResponse, body) => {
if (err) {
return console.error('upload failed:', err);
}
console.log('Upload successful! Server responded with:', body);
},
Has anybody out there been able to use this endpoint successful using node.js?