POST create inventory count item /question on request body

Hi I just have a question regarding what it is allow to send on the body of the request for the POST InventoryCountItem.json.

The example on your site shows only an object included in the request.

$ curl -X POST -H "Authorization: Bearer {Access Token}" \
-d '{
      "qty": "40",
      "inventoryCountID": "2",
      "itemID": "46",
      "employeeID": "1"
    }' "https://api.lightspeedapp.com/API/Account/{accountID}/InventoryCountItem.json"


  1. Is it allowed to submit an array of objects, so we can add more than one item instead of doing one api call per item?
  2. Also, the example doesn't use the inventoryCountItemID. However, that's required, right?

Can we do this?:

$ curl -X POST -H "Authorization: Bearer {Access Token}" \
-d 
'[
    {
      "inventoryCountID": "random_generated_id",
      "qty": qty,
      "inventoryCountID": ID,
      "itemID": "item_id_0",
      "employeeID": "1"
    },
    {
      "inventoryCountID": "random_generated_id1",
      "qty": qty,
      "inventoryCountID": ID,
      "itemID": "item_id_1",
      "employeeID": "1"
    }
]
' "https://api.lightspeedapp.com/API/Account/{accountID}/InventoryCountItem.json"

Thanks for the help,

Mikel Rodriguez

Tags:

5 comments

  • gregaricangregarican Member Posts: 1,061 

    Sounds like it should work. I'd just try it out and see what the API response is. I've found a lot of the less-documented areas of the API take a bit of trial and error. And I've also found that if I perform a GET request for some data, I can review the response and use that format for what I need for a POST/PUT request to the API endpoint.

  • mikel362dmikel362d Member Posts: 3

    Perfect, thanks for your prompt response

  • mattangermattanger Member Posts: 113 

    I don't think posting multiple items will work. It should work like that, but last time I tried, it would only create the first item in the list. As stated, you might as well try it out. I'd love to know if to if it works for you!

    Matt Anger

    https://spectraretail.com/

  • mikel362dmikel362d Member Posts: 3

    Hey Matt, thanks for your answer as well. I tried it out and as you mentioned it didn't work. I had to individually add each item. Had to do one api call per item.

    Thank you both for your answer

  • gregaricangregarican Member Posts: 1,061 

    Thanks for the follow up. Shame it an array couldn't be passed in. Especially seeing that the POST/PUT API requests are usually throttled at like one call every 10 seconds. If you have a lot of records to update it could take awhile. 😕

Sign In or Register to comment.