Get a list of product images
we can get all image information for the product with SKU “Test Product”.
curl --location 'http://buildcorpdirect.com/rest/default/V1/products/Test Product/media'
--header 'Content-Type: application/json'
--header 'Accept: application/json'
--header 'Authorization: Bearer {token}'
Add a new image
we can add the following image to the product with SKU “Test Product”.
curl --location 'http://buildcorpdirect.com/rest/default/V1/products/Test Product/media'
--header 'Content-Type: application/json'
--header 'Accept: application/json'
--header 'Authorization: Bearer {token}'
--data '{
"entry": {
"media_type": "image",
"label": "test Image Number 7",
"position": 6,
"disabled": false,
"types": [ "image",
"small_image",
"thumbnail"],
"content": {
"base64_encoded_data": "iVBORw0KGgoAAAANSUhEUgAAAPAAAAEcCAIAAAB2xq6IAAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAGYktHRAD/AP8A/6C9p5MAAHiMSURBVHja7f1puCXZVR4Iv2utvXfEKsmRo99vaqCZhRDMtLFqZqIm7px+M1F7l29D+maWAEH2mD4zV1XV7XYHWyPf9Y1OTZ58qjvsFABINKXLcK2uCuXCAtzMmq8J/3/jS7Biaf5+DwAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyNS0xMS0yNVQwNDo1MDowMCswMDowMOoboSkAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjUtMTEtMjVUMDQ6NTA6MDArMDA6MDCbRhmVAAAAKHRFWHRkYXRlOnRpbWVzdGFtcAAyMDI1LTExLTI1VDA0OjUwOjAwKzAwOjAwzFM4SgAAAABJRU5ErkJggg==",
"type": "image/png",
"name": "custom_image_7.png"
}
}
}'
Update an image
we can update an existing image with the id of 694
curl --location --request PUT 'http://buildcorpdirect.com/rest/default/V1/products/Test Product/media/694'
--header 'Content-Type: application/json'
--header 'Accept: application/json'
--header 'Authorization: Bearer {token}'
--data '{
"entry": {
"id": 6725,
"media_type": "image",
"label": "test Image Number 8",
"position": 6,
"disabled": false,
"types": [],
"content": {
"base64_encoded_data": "iVBORw0KGgoAAAANSUhEUgAAAOcAAADqCAIAAADWCMWpAAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAGYktHRAD/AP8A/6C9p5MAAC5uSURBVHja7X1rbFvH2ebMnHN4eJMoiSLtWHZ8qd06d5CYII=",
"type": "image/png",
"name": "custom_image_8.png"
}
}
}'
Delete an image
we can delete an image from a SKU. In this example, we’ll use the image id of 695.
curl --location --request DELETE 'http://buildcorpdirect.com/rest/default/V1/products/Test Product/media/695'
--header 'Content-Type: application/json'
--header 'Accept: application/json'
--header 'Authorization: Bearer {token}'