Upload image API REST
-
hello, I have installed a clean version of wordpress and added woocommerce.
From an ERP I add the products, categories via API REST, all this without problem.
But when I try to add the images I find several errors that took weeks without finding a solution.
If I try to add the images when I update the product according to the woocommerce documentation (https://woocommerce.github.io/woocommerce-rest-api-docs/#create-a-product) I receive the error 400. I check the json file that sending via API REST and has the same structure indicated in the documentation. Example
{
“name”: “Bicycle bh 95b”,
“slug”: “BICYCLE HB”,
“description”: “Biciclet hb dedicated to road.”,
“short_description”: “Bicycle bh 95b”,
“sku”: “70068”,
“regular_price”: “525”,
“sale_price”: “”,
“external_url”: “”,
“button_text”: “”,
“tax_class”: “”,
“manage_stock”: “false”,
“stock_quantity”: “22”,
“stock_status”: “instock”,
“weight”: “0”,
“shipping_class”: “”,
“average_rating”: “0.00”,
“rating_count”: “0”,
“parent_id”: “0”,
“purchase_note”: “”,
“categories”: [
{
“id”: “17”
}
],
“images”: [
{
“src”: “https: // <www.myweb.es> /html/wp-content/uploads/2019/04/70068_P1.jpg”
}
]
}
With this json I receive error 400.I also tried to do it via endpoint media “/ wp-json / wp / v2 / media” to insert the image in the media library first and in this case I receive the unauthorized 401 error. The user with whom I am connecting the API is an administrator. The json sent it with the image in binary. The user has passed it as a parameter or adding to the header and I receive the same error.
I do not know how to upload images, to see if you can give me a solution.Thank you.
The page I need help with: [log in to see the link]
The topic ‘Upload image API REST’ is closed to new replies.