2

I am trying to POST to

192.168.2.153/rest/V1/products/{MYSKU}/media

I used several online picture to BASE64 converter to convert to BASE64.

The first line looks like

data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAA

And here is my body (without the BASE64 code to save space here):

{
"entry": {
"media_type": "image",
"label": "new_picture",
"types": [
  "image"
],
"file": "pic1.jpg",
"content": {
  "base64_encoded_data": "",
  "type": "image",
  "name": "pic1.jpg"
}
  }
}

I am only getting

The image content must be valid base64 encoded data.

Whatever I try no luck.

1 Answer 1

3

The base64_encoded_data should start with /9j/4AAQSkZJRgABAQEAYABgAA, no need to add data:image/jpeg;base64, before the type also should be image/jpeg

the final json should be

{
  "entry": {
    "media_type": "image",
    "label": "new_picture",
    "types": [
      "image"
    ],
    "file": "pic1.jpg",
    "content": {
      "base64_encoded_data": "/9j/4AAQSkZJRgABAQEAYABgAA.........",
      "type": "image/jpeg",
      "name": "pic1.jpg"
    }
  }
}
1
  • I tried to upload image in media but image is not uploaded but in media blank path is generated "media/tmp/catalog/product/c/h" Please help me how can upload image. Commented Nov 6, 2020 at 10:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.