- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Buongiorno a tutti.
Sto tentando di eseguire la modifica dei parametri di un prodotto tramite API Rest di Magento2.
Eseguo la chiamata
"http://MIOPERCORSO:8080/rest/V1/products/{"product":{"id":"1","sku":"ABCDEF","custom_attributes":{"attribute_code":"Description","value":"PROVA"}},"saveOptions":true}"
ma mi viene restituito l'errore
[messagerotected] => Client error: `PUT http://MIOPERCORSO:8080/rest/V1/products/ABCDEF/%7B%22product%22:%7B%22id%22:%223194%22,%22sku%22:%22ABCDEF%22,%22custom_attributes%22:%7B%22attribute_code%22:%22Description%22,%22value%22:%22prova%22%7D%7D,%22saveOptions%22:true%7D` resulted in a `404 Not Found` response:
{"message":"Request does not match any route."}
ma il prodotto nel DB di Magento esiste.
Qualche suggerimento?
Grazie
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you.
I've tryed this solution in Postman and it works, I can read new description by the execution of GET method for the call, but Description field in backend session for this product didn't change. Have I modify another field instead of custom_attributes > "attribute_code": "description" ?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: modifica descrizione prodotto Magento2
Hello @roberto_de ga
"Request does not match any route" means you are not calling API properly something wrong.
To create product, we can use:
- POST: /V1/products
For updating:
- PUT: /V1/products/{sku}
In your case, your code should be:
$productData = [ 'attribute_set_id' => 4, "type_id": "simple", "sku": "test-SKU", "name": "Test", "price": 100, "status": 1, 'custom_attributes' => [ ['attribute_code' => 'description', 'value' => 'Test Description' ], ['attribute_code' => 'short_description', 'value' => 'Test Short Description' ], ] ];
The JSON body:
{ "product": { "sku": "test-SKU", "name": "Test", "attribute_set_id": 4, "price": 100, "status": 1, "custom_attributes": [ { "attribute_code": "description", "value": "Test Description" }, { "attribute_code": "short_description", "value": "Test Short Description" } ] } }
Please follow and let me know if you are still facing any issue.
https://www.manishmittal.com/
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you.
I've tryed this solution in Postman and it works, I can read new description by the execution of GET method for the call, but Description field in backend session for this product didn't change. Have I modify another field instead of custom_attributes > "attribute_code": "description" ?