Create an Item

shulianshulian Member Posts: 4

Hi u all!


I am trying to create an Item using this endpoint

POST /API/Account/{accountID}/Item.json

but I get his error:

"{"httpCode":"400","httpMessage":"Bad Request","message":"Item not created. An Item must have a description.","errorClass":"Exception"}"

I would like to know which are required fields because I cannot find that information in API documentation.

https://developers.lightspeedhq.com/retail/endpoints/Item/#post-create-an-item

Thank you in advance

10 comments

  • gregaricangregarican Member Posts: 906 

    It's logical that the item description is required, since not all Retail web UI forms display the SystemID to identify the item. The required fields indeed aren't noted in the API docs. Usually what I do as a rule is provide all elements in my request payload. Those without values that I don't care about I just pass along as "". That way there is no ambiguity.

  • shulianshulian Member Posts: 4

    Hello Gregarican.

    I added the description and now it's not complaining so I think there are no more required fields.

    BTW I am sending upc, customSku, description and Prices.

    Thank you!

  • eyupeyup Member Posts: 4

    Hi I am trying to create an item too, but i get different error

    <?xml version="1.0"?>

    <Error><httpCode>405</httpCode><httpMessage>Method Not Allowed</httpMessage><message>The requested resource does not allow that action.</message><errorClass>Exception</errorClass></Error>

  • Ali_MasoumieAli_Masoumie Moderator, Lightspeed Staff Posts: 340 moderator

    Hi @eyup,

    Can you send some more details ( endpoint & full request + response)?

  • gregaricangregarican Member Posts: 906 

    @eyup usually the HTTP 405 response code means that you are sending a request method type that the server cannot fulfill. For example, if you send a POST request to an endpoint that only accepts GET requests. So make sure you are referencing the correct endpoint URI and double check your method type.

  • eyupeyup Member Posts: 4

    Sorry for late answer, I solved the problem, i made some simple mistakes...

    Now i can create item,but how can i change the quantity?

  • mattangermattanger Member Posts: 106 ✭

    To set quantities you have to set the ItemPrices object. i.e

    {

    description: "item",

    Prices: { ItemPrice: [{ shopID: 0, qoh: 1 } ]

    }

    }

    This isn't a working example, but it'll probably get you started

    Matt Anger

    https://spectraretail.com/

  • eyupeyup Member Posts: 4

    I added like this, item created but quantity still same


    {

      "description": "Green Apple",

    "defaultCost": 100,

      "discountable": true,

      "tax": true,

      "itemType": "default",

      "serialized": false,

      "modelYear": 0,

      "upc": "",

      "ean": "",

      "customSku": "",

      "manufacturerSku": "",

      "publishToEcom": false,

      "categoryID": 0,

      "taxClassID": 1,

      "departmentID": 0,

      "itemMatrixID": 0,

      "manufacturerID": 0,

      "seasonID": 0,

      "defaultVendorID": 0,

      "Prices": {

        "ItemPrice": [

          {

    "shopID": "0", 

    "qoh": "1",

            "amount": 150,

            "useTypeID": 1,

            "useType": "Default"

          },

          {

    "shopID": "0", 

    "qoh": "1",

            "amount": 145,

            "useTypeID": 2,

            "useType": "MSRP"

          }

        ]

      }

    }

  • mattangermattanger Member Posts: 106 ✭

    Whoops. I told you wrong. It's actually the ItemShop that needs updating.

    Something like this

    {ItemShops: { ItemShop: [{shopID: 0, qoh: 12}]}

    Matt Anger

    https://spectraretail.com/

  • eyupeyup Member Posts: 4

    I did... Thanks everybody!


    PUT https://api.lightspeedapp.com/API/V3/Account/{accountID}/Item/61717.json

    {

    "description":"Green Apple",

        "ItemShops": {

                    "ItemShop": [

                        {

                        "itemShopID": "403390",

                        "qoh": "20",

                        "itemID": "61717",

                        "shopID": "1"

                    }

                  ]

        }

    }


Sign In or Register to comment.