Add SaleLine to Open Sale

abailieabailie Member Posts: 5

I'm trying to add a saleline to an open sale, but it keeps getting rejected.


I’m POSTing to the https://api.lightspeedapp.com/API/Account/{accountID}/Sale/{saleID}/SaleLine endpoint and I keep getting the response:

{

    "httpCode": "400",

    "httpMessage": "Bad Request",

    "message": "SaleLine must have both tax and taxClassID set or itemID set. Set taxClassID to 0 to specifically negate having a TaxClass",

    "errorClass": "SaleError",

    "saleID": "346"

}

I've tried so many different values in the JSON body, and always the same response, even when all he values listed are set.


Can someone show me a sample JSON body for the POST request?


Thanks for your help

Tags:

5 comments

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 991 moderator

    Hi @abailie,

    Thank you for reaching out to us.

    Please check our documentation for all saleline fields https://developers.lightspeedhq.com/retail/endpoints/Sale-SaleLine/

  • abailieabailie Member Posts: 5

    Hi,

    Thanks for your prompt response. I had just realised that I was wrapping the JSON settings in an outer saleLine tag, something like this:

    {

    "saleLine": {

    "saleID": "{saleID}",

    ....

    }

    }


    removing the saleLine wrapper fixed the problem.

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 991 moderator

    Okay perfect!

  • namratanamrata Member Posts: 5

    hello,

    I am sending this code but I am getting the same error

    code- {

        "employeeID":1,

        "registerID":1,

        "completed":"true",

        "shopID":1,

        "customerID":1,

        "SaleLines":{

           "SaleLine":[

              {

                 "itemID":1,

                 "unitQuantity":1,

                 "tax":true,

                 "unitPrice":"100",

                 "taxClassID":1,

                 "discountID":"9"

              }

           ],

           "Discount":[

              {

                 "discountID":"9",

                 "name":"€10 Discount",

                 "discountAmount":"-10"

              }

           ]

        },

        "SalePayments":{

           "SalePayment":{

              "amount":90,

              "paymentTypeID":1

           }

        },

        "ShipTo":{

           "shipped":"true",

           "shipNote":"Test 0001",

           "firstName":"lucien api",

           "lastName":"versendaal api",

           "customerID":"1",

           "Contact":{

              "Addresses":{

                 "ContactAddress":{

                    "address1":"teststreet 1",

                    "city":"Amsterdam",

                    "state":"Noord-Holland",

                    "zip":"1054BN",

                    "country":"Netherlands, The"

                 }

              },

              "Phones":{

                 "ContactPhone":{

                    "number":"06112345698",

                    "useType":"Home"

                 }

              },

              "Emails":{

                 "ContactEmail":{

                    "address":"[email protected]",

                    "useType":"Primary"

                 }

              },

              "Websites":""

           }

        }

     }


    and response- stdClass Object
    (
        [httpCode] => 400
        [httpMessage] => Bad Request
        [message] => SaleLine must have both tax and taxClassID set or itemID set. Set taxClassID to 0 to specifically negate having a TaxClass
        [errorClass] => SaleError
        [saleID] => 4
    )
    
    what I am doing wrong please suggest me
    


  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 991 moderator

    Hi @namrata,

    Please check the answer from @abailie.

    "removing the saleLine wrapper fixed the problem."

Sign In or Register to comment.