Magento 2 - How to upload image to REST API (POST)
If you want to upload product image using rest api. You need to pass below parameters in your request.
Your media upload url - http://127.0.0.1/megento2/index.php/rest/V1/products/{sku}/media.
Method name - Post
Below are the body parameters :
[
{
"id": 0,
"media_type": "test",
"label": "test",
"position": 0,
"disabled": true,
"types": [
"thumbnail"
],
"file": "test.png",
"content": {
"base64_encoded_data": "Here i have passed base64_encoded data of image",
"type": "file/png",
"name": "test.png"
},
}
}
]
Note : Make sure you pass base64_encoded_data of image.