magento2: REST API "The product can't be saved"
Another case of bad error message feedback.
No logs other than the REST API giving terrible error message and a whole bunch of Googling has to be done.
In my case I tried to upload an image through the rest API using POST to /rest/V1/products/<sku>/media
The issue has to do with products having required fields that are not filled in. This could arise after changing attribute sets and not going back to fix it on old products for example.
The solution is to go into admin, filling in the required fields for the product, then trying to upload the image again.
Preconditions (*)
- Magento 2.3.3
Steps to reproduce (*)
- Have required fields on product that are not filled in
- Try to upload image using REST API
Expected result (*)
- Better error message that is actually helpful.
- Log output in var/log
Actual result (*)
- Terrible error message.
- No logs
- Not being able to upload the product image
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 3
- Comments: 21 (3 by maintainers)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 28 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!
Posting a comment. Issues should not be automatically closed.
@Zyles , thank you for your report. Looks like it would be good solution to add output with stack trace in var/log. For now response is
"message": "The product can't be saved."
Marked as Future Request cc @sdzhepaIf you’re using a Bitnami docker image, make sure
/opt/bitnami/php/tmp
is writeable by PHPRun this inside the magento container terminal:
chmod 777 /opt/bitnami/php/tmp
Doing this solved the “The product can’t be saved” for me