skip to Main Content

I am trying to update base price of product by store id and product SKU using POSTMAN. But, getting error Invalid Attribute. Sometimes it works fine. I tried to change product attributes to if it cause to this issue but it didn’t resolved the issue.

Request URL –

{{url}}/V1/products/base-prices

Request Body –

{
    "prices": [
        {
            "price": 38,
            "store_id": 4,
            "sku": "WEBPRICETEST"
        }
    ]
}

Response –

[
    {
        "message": "Invalid attribute %fieldName = %fieldValue.",
        "parameters": [
            "SKU",
            "WEBPRICETEST"
        ]
    }
]

There is no any traces in error log.

3

Answers


  1. So basically if both success and error request payload are some and it gives error with few of SKUs then it may be the type of product which is causing error. The endpoint you are using will only update below types of product base price.

    Simple,
    Virtual,
    Downloadable,
    Bundle (fixed price type only).

    https://devdocs.magento.com/guides/v2.4/rest/modules/catalog-pricing.html#set-base-prices

    Login or Signup to reply.
  2. Magento already supports getting prices by store. You just need to add store_code and URL: {{url}}/{store code}/V1/products/base-prices

    Login or Signup to reply.
  3. This error could appear if you try to use the wrong type of a request.

    Try this

    POST(not PUT or any other): <domain>/rest/V1/products/base-prices

    OR (for async request): POST <domain>/rest/async/V1/products/base-prices

    Body

    {
      "prices": [
      {
        "price": 222,
        "store_id": 2,
        "sku": "SKU-1"
      },
      {
        "price": 333,
        "store_id": 2,
        "sku": "SKU-2"
      }
      ]
    }
    

    Don’t forget to set headers:

    Content-Type : application/json

    Authorization: Bearer <Your Access Token>

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search