I'm pretty new to Magento and I was trying to add a media to a existing product. From code I am able to do that as the following:
$entry = ['entry' => [
'media_type' => ---,
'position' => ---,
'types' => [
---,
---,
---,
],
'file' => ---,
'content' => [
'base64_encoded_data' => base64_encode(---),
'type' => ---,
'name' => ---,
]
]
];
if (---) {
$entry['entry']['id'] = ---;
}
$saveMedia->whereSku($sku)
->withData($entry)
->save();
The code is working "fine" I am actually trying to use a POST to update an existing image specifing the id but that part it's not working and I get a new image. When I got this error I tried to do the same POST in postman and when I specify in the body the same code as above in json the following error appears:
{
"message": "%fieldName is a required field.",
"parameters": {
"fieldName": "entry"
},
}
My json is as following:
{"entry":{"media_type":"---","position":---,"types":["image","small_image","thumbnail"],"file":"---","content":{"base64_encoded_data":"---","type":"image\/jpeg","name":"---"},"id":---}}
So:
- How do I fix this error? Why isn't my entry recognized?