Invalid data input when doing POST for product image.

in Development
Hi,
I have code which works on my development machine, but not on the production server. I can't figure out why. The error I get is too cryptic.
{"error":{"code":400,"method":"CREATE","request":"\/nl\/products\/128766768\/images.json","message":"Invalid data input."}}
I checked the requests which seems fine. Contents of data array in attachment.
I decoded this with an online tool, the image works fine. You can try it out here: https://devpal.co/base64-image-decode/
I am using the seoshop/seoshop-php package as a client like this: $this->client->productsImages->create($productId, $data);
It works locally, not on production. Any ideas what the problem could be?
3 comments
Hi @AQM,
Thank you for contacting us.
In your data.txt I see that you're sending data:image/jpeg;base64, this isn't needed. Please send it like I did below:
To convert the image to a base64 encode I used this code:
I hope this helps.
Hi Lucien,
Thanks for your reply. The thing is, it works on my development machine. The images are added to the products over the API. I can see product images in de backend of our Lightspeed app.
I just tried your suggestion. Now I get the following error on production:
"Caught exception: SplFileObject::__construct(/9j/4AAQSkZJRgABAQEAYABgAAD//gA8Q1JFQVRPUjogZ2QtanBlZyB2MS4wICh1c2luZyBJSkcgSlBFRyB2NjIpLCBxdWFsaXR5ID0gMTAwCv/bAEMAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE
BAQEBAQEBAf/bAEMBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIA7ID6AMBEQACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHB
FVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEB
AMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAw
EAAhEDEQA/AP7+KACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACg\n"
Hi,
Please use the code Lucien sent to encode your image: