1

I have creating product using rest API but image upload not working.

API: baseurl/rest/V1/products

Method: POST

Body:

{
  "product": {
    "sku": "info",
    "name": "Info",
    "attribute_set_id": 4,
    "price": 1000,
    "status": 1,
    "custom_attributes": [
        {
            "attribute_code": "category_ids",
            "value": ["41","42","43"]
        },      
        {
          "attribute_code": "description",
          "value": "Lorem Ipsum is simply dummy text of the printing and typesetting industry."
        },      
        {
            "attribute_code": "image",
            "value": "image1.jpg"
        },
        {
            "attribute_code": "thumbnail",
            "value": "image2.jpg"
        },
        {
            "attribute_code": "small_image",
            "value": "image12.jpg"
        }
    ],
    "visibility": 4,
    "type_id": "simple",
    "weight": 1,
        "extension_attributes": {
            "stock_item": {
                "qty": "110",
                "is_in_stock": true
            }
        }
    },
    "saveOptions": true
}

Any help would be appreciated. Thanks!

0
0

Maybe base64_encoded_data is missing, once check with that. and check format of all images that are used.

0

This is not possible using the Magento 2 REST API. Up to Magento 2.2 REST API only supports single object calls at a given time for image calls. You need to call multiple calls for multiple images.

if you still wanted to upload multiple images, you can do it by calling that function in the looping structure.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.