Can you make multiple changes in 1 PUT request?

darryl_ssdarryl_ss Member Posts: 65

Hi,

Can you make multiple changes in 1x PUT request? i.e:

{ "ItemShops": { "ItemShop": [{ "itemShopID": "15392", "qoh": 1 }]}, "Prices": {"ItemPrice": [{ "amount": 49.95 }]}}

How should that be formed?

Thanks,

Tags:

9 comments

  • gregaricangregarican Member Posts: 511 

    Have you read through the API documentation? For a single item, you can issue a PUT request to update multiple properties. Described here --> https://developers.lightspeedhq.com/retail/endpoints/Item/#put-update-an-item.

  • darryl_ssdarryl_ss Member Posts: 65

    Aye, I read the docs and saw that it says that you can update multiple properties in one PUT request. Thanks for the link.

    My issue is more related to the form that my PUT request should take as the API issues an error when trying to update the price at the same time as the qoh.

    I thought that reaching out to the community may help.

  • gregaricangregarican Member Posts: 511 

    Gotcha. Here is an example request JSON body that would update a product note, the product's on-hand availability, and the product's pricing. I'd have to reference the correct item in my query's URL (e.g. - https://api.merchantos.com/API/Account/{accountId}/Item/{itemId}.json), as well as ensure that this item is defined in shop 1 as itemShopID 164, and ensure that useType and useTypeID's are correct.


     "Note": { 

      "note": "This is a newly-updated note." 

     },

     "ItemShops": {

      "ItemShop": {

       "itemShopID": 164,

       "shopID": 1,

       "qoh": 1

      }

     },

     "Prices": {

       "ItemPrice": [

        {

         "amount": "400",

         "useTypeID": "1",

         "useType": "Default"

        },

        {

         "amount": "275",

         "useTypeID": "2",

         "useType": "MSRP"

        },

        {

         "amount": "320",

         "useTypeID": "3",

         "useType": "Online"

        }

       ]

      }

     }

  • darryl_ssdarryl_ss Member Posts: 65

    Hi,

    I'm trying with:

    {"Prices": { "ItemPrice": [{ "amount": "49.95" }] }}
    

    Which I think should work, but the API returns:

    {
      "httpCode": "404",
      "httpMessage": "Not Found",
      "message": "Unknown PriceLevel .",
      "errorClass": "UnknownPriceLevel"
    }
    

    Unknown price level, is it indicating that it does not like the "." in the price?

  • gregaricangregarican Member Posts: 511 

    Perform a GET request on this same item and you should see what the API is looking for when it comes to prices. There are different "use types" when it comes to prices.

  • gregaricangregarican Member Posts: 511 

    Here is what the price levels look like in the front end UI. Even if you only have a single price level per item you'd presumably need to specify it when changing prices via the API.



  • gregaricangregarican Member Posts: 511 

    ...so did referencing a valid price level in your PUT call solve your issue?

  • darryl_ssdarryl_ss Member Posts: 65

    Hi @gregarican, this one is on my todo list to resolve. I'll let you know when I get back to it! ;)

  • darryl_ssdarryl_ss Member Posts: 65

    @gregarican Yes it was the 'useType' & 'useTypeID' that were missing. Thanks.

Sign In or Register to comment.