Simple image adding to product or variant, who can give a working example?
I read many discussions, but i still can't manage to simply upload an image to my ecom-site.
I can't figure out the body image to base64-decode and the API-tutorials doesn't really give me the answer.
it always return: "Error parsing attachment: We were unable to upload this image as this type of image is not supported. We support JPG, JPEG, GIF, PNG images"
This is my Json body:
{ "variant": { "image": { "attachment": "Li8=", // path= './' "filename": "plaatje.jpg" } } }
I guess the attachment should be corrected, but how to correct/where to find this image body format?
Thx in advance,
Ron
2 comments
Hi @Ron23,
Thank you for contacting us.
You can use something like this to convert your image to a base64 attachment, https://stackoverflow.com/questions/3967515/how-to-convert-an-image-to-base64-encoding or an online tool like: https://www.base64-image.de/
I hope this helps.
It works, thanks,
But i feel ashame now, because i was suprised by the fact that image-body was really "image-body"!
Tutorial also says '' .. or the path of picture", so less overhead thinking the filename content was used to pass the image and only the pass was 64-coded. This was unclear to me, so shame to me. But thanks.