3

I'm requesting products list using the following API call GET /V1/products

http://127.0.0.1/magento2github/index.php/rest/default/V1/products?searchCriteria%5BpageSize%5D=100000&searchCriteria%5BcurrentPage%5D=1

That gives me the following response:

{
  "items": [
    {
      "id": 1298,
      "sku": "2000315",
      "name": "testProduct",
      "attribute_set_id": 4,
      "price": 5,
      "status": 1,
      "visibility": 4,
      "type_id": "simple",
      "created_at": "2015-12-29 19:51:31",
      "updated_at": "2015-12-29 19:53:09",
      "weight": 0,
      "product_links": [],
      "options": [],
      "tier_prices": [
        {
          "customer_group_id": 0,
          "qty": 1,
          "value": 5.75
        },
        {
          "customer_group_id": 1,
          "qty": 1,
          "value": 5.75
        },
        {
          "customer_group_id": 26,
          "qty": 1,
          "value": 5.35
        },
        {
          "customer_group_id": 27,
          "qty": 1,
          "value": 5.75
        }
      ],
      "custom_attributes": [
        {
          "attribute_code": "description",
          "value": "<p>Some description about this item comes here...</p>"
        },
        {
          "attribute_code": "image",
          "value": "/w/i/wijn1_back_1.jpg"
        },
        {
          "attribute_code": "small_image",
          "value": "/w/i/wijn1_back_1.jpg"
        },
        {
          "attribute_code": "thumbnail",
          "value": "/w/i/wijn1_back_1.jpg"
        },
        {
          "attribute_code": "options_container",
          "value": "container2"
        },
        {
          "attribute_code": "required_options",
          "value": "0"
        },
        {
          "attribute_code": "has_options",
          "value": "0"
        },
        {
          "attribute_code": "url_key",
          "value": "testproduct"
        },
        {
          "attribute_code": "swatch_image",
          "value": "/w/i/wijn1_back_1.jpg"
        },
        {
          "attribute_code": "tax_class_id",
          "value": "2"
        }
      ]
    }
  ],
  "search_criteria": {
    "filter_groups": [],
    "page_size": 100000,
    "current_page": 1
  },
  "total_count": 1
}

If you look at custom_attributes array you will only see the base image. How can I retrieve the other images configured in Magento2?

enter image description here

4

It is possible to iterate over products and retrieve images using GET /V1/products/:sku/media, there does not seem to be a way without multiple requests.

  • thanks, must have looked over that operation. Can confirm I get both images now. One more api call isn't an issue! – emp Dec 31 '15 at 12:20
  • @emp does the json data helps to add images via default api in magento 2.3 ? hope it has to be base64 encode – insoftservice Aug 20 at 19:16

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.