Closed ericahoekerd closed 8 years ago
Same here with REST API, "cannot save product", with an image, either with POST /V1/products/{sku}/media and POST /V1/products
try to add the file-extension to the name (.jpg) For me it worked with following payload and REST-API at 'http://0.0.0.0/index.php/rest/default/V1/products/24-MB01/media': { "entry": { "mediaType": "image", "label": "Testbild", "position": 1, "disabled": false, "types": [ "thumbnail" ], "content": { "base64EncodedData": "...base64...", "type": "image/jpeg", "name": "TestName.jpg" } } }
Thank you, that worked. The Magento2 API docs are horrible. No examples or accepted formats anywhere. Even error messages are blurred.
Glad it helped!
@tinxit please let us know if you still have an issue.
wow! This works now! Strange work around altough :-)
issue was closed, if you'll find another scenarios please write here, or add another issue
strange workaround, but this is indeed working, we will put in the label name always the extension of the image
It is not possible to attach an image with this method: catalogProductAttributeMediaGalleryManagementV1CreateRequest . The product with sku 189 exists in Magento backend, but I get an error 'Cannot save product'. The error comes from this line
$product = $this->productRepository->save($product) in this function:
public function create($sku, ProductAttributeMediaGalleryEntryInterface $entry) { /* @var $entry ProductAttributeMediaGalleryEntryInterface / $entryContent = $entry->getContent();
I have debugged but I am not able to solve it why I get this error message. If I assign the same image in the backend it will succeed.
This is the XML request, the format is ok: <?xml version="1.0" encoding="UTF-8"?>
-
-soap:Body
-def:catalogProductAttributeMediaGalleryManagementV1CreateRequest
-
-
-
/def:catalogProductAttributeMediaGalleryManagementV1CreateRequest
/soap:Body
/soap:Envelope