SaleLines.Item in return relations

messhiasmesshias Posts: 35Member

I noticed since the last 4 days after the sale is done by API it'll not returning anymore the SaleLines.Item of the same.


This is not good because we need the items to put on our receipt and do a additional request to that is not a smart and clean solution.


What happened?


Screenshot of the sale return JSON object:


Thank you

21 comments

  • Alex LugoAlex Lugo Posts: 132Administrator, Lightspeed Staff moderator

    Hello @messhias,

    I check with our Dev Team and the Item object hasn't been loaded inside the SaleLine. The itemID is present on each SaleLine.

    Alex Lugo
    API Support Specialist
    Lightspeed HQ
  • messhiasmesshias Posts: 35Member

    Hello, some feedback about this subject?

  • gregaricangregarican Posts: 270Member 

    I am curious as well. Looking back at some test API calls I made to the Sale endpoint back in February, the response included numerous relations. Including what appears to be the Item collection. Obviously, it's more efficient to pull the various relations in one API call, as opposed to make multiple calls to retrieve these other collections.

    So does this mean that the API was recently changed? If so, are the some sort of formal announcements made to RSS feed subscribers for this discussion site? If not, that's definitely a concern...

  • messhiasmesshias Posts: 35Member

    My endpoint isn't returning anymore... And I'm still waiting a response, we didn't changed anything of our endpoint and suddenly isn't returning anything else.

  • messhiasmesshias Posts: 35Member

    Before anyone say again to check the endpoint, I was working with this endpoint since the beginning and everything's work well, this is start happens three weeks ago.

  • messhiasmesshias Posts: 35Member


    The endpoint we are using since the beginning when we create a new sale: https://api.lightspeedapp.com/API/Account/{accID}/Sale.json?load_relations=["ShipTo","ShipTo.Contact","Discount","Customer","Customer.Contact","SalePayments","SalePayments.PaymentType","SalePayments.CCCharge","SalePayments.SaleAccounts","SalePayments.Signatures","SaleLines","SaleLines.Item","SaleLines.Discount","SaleLines.TaxClass","SaleLines.TaxCategory","SaleLines.Note","TaxCategory","TaxCategory.TaxCategoryClasses","Quote"]


    This endpoint it worked, but some days (between 2-3 days) before this post a lot endpoints of SaleLines isn't working anymore, we checked now isn't not only the SaleLines.Item. The SaleLines.Discount, SaleLines.TaxClass, SaleLines.TaxCategory, SaleLines.Note, summaryze, anything of SaleLines is not working, and it's been since 3 weeks I requested the answer and so far is nothing.


    So, just let me know, this is a bug, a change of api?


    Because if it's a change of api we'll need grab this information individually using our bucket size for each sale and etc...


    Thank you.

  • gregaricangregarican Posts: 270Member 
    edited March 11

    Sorry you haven't heard a response as to the root cause. When I pasted your load_relations into my previously-successful test case, the API query failed. Here was the response:

    {

      "httpCode": "400",

      "httpMessage": "Bad Request",

      "message": "Tried to load a relation that is not allowed: SaleLines.TaxCategory",

      "errorClass": "InvalidQueryException"

    }


    When I left out SaleLines.TaxClass and SaleLines.TaxCategory from the relations I received a successful response, with the Item collections in there. One thing I have encountered is delayed response times with complex relations being requested. Which is understandable, seeing that more complex SQL table joins can sometimes slow down getting a result set. But as long as nothing times out it should work.


    In your case it seems like your result set is missing the relations you requested. My guess would be some sort of API change to the api.lightspeedapp.com host. Since I am hitting api.merchantos.com perhaps that explains something? If no one from API Support is chiming in I'm just guessing :(

  • messhiasmesshias Posts: 35Member

    Yes, our api's some endpoints seems equals but not always returns the same relations, but in my case I'm using the retail, and so far nothing from lightspeed.


    And sincerely, doesn't matter at all because we're working in that


    @Adrian Samuel we have some feedback from dev team?


    Thank you.

  • gregaricangregarican Posts: 270Member 

    It's been awhile so I might be wrong, but can you try the api.merchantos.com host instead of the api.lightspeedapp.com host for your API call? To see if it makes any difference in the API response set you're getting. I know there were some slight differences between the two awhile back. For example, one required TLS 1.2, whereas the other still accepted legacy TLS communication. I know that has nothing to do with your situation, but still something that might be worth a shot, since there isn't any feedback from the mods on here yet :)

  • messhiasmesshias Posts: 35Member
    edited March 13

    Hello @gregarican , thank you, we cannot use this endpoint because it's different and for eComm.


    The right thing is Alex Lugo or anyone of LS answer us and tell us what's happening.


    Thank you.

  • gregaricangregarican Posts: 270Member 

    I'm not so sure about the host being only for eCom. We don't use eCom, we just use Retail, and I use that host name for my API requests. :)

  • Adrian SamuelAdrian Samuel Posts: 474Moderator, Lightspeed Staff moderator

    @messhias to my knowledge the Item relation Object was never loaded in the Sale endpoint by default unless you specified it. For SaleLines with items, you would always receive the itemID from which you could make another request.

    We are not aware of any recent changes in the API.

    Could you send me what was the original payload?

    My tests returned what was expected across the different

    Adrian Samuel

    API Integrations Consultant - Strategic Solutions

    Lightspeed HQ

  • messhiasmesshias Posts: 35Member

    Hello @Adrian Samuel , so for now after a sale I have to do another request to request to get the Items after the post? So what's the point has the relation SaleLines.Item in the request?


    Maybe the documentation for retail isn't updated.


    I don't have the previously requests, and now isn't returning anymore to show you the example.


    Thank you

  • Adrian SamuelAdrian Samuel Posts: 474Moderator, Lightspeed Staff moderator

    @messhias, please send an example payload that you send to Lightspeed and I'll be able to answer your question

    Adrian Samuel

    API Integrations Consultant - Strategic Solutions

    Lightspeed HQ

  • messhiasmesshias Posts: 35Member

    Good morning,


    Here's my post payload:



    This is the data I'm sending in post to my api endpoint.


    Thanks.

  • messhiasmesshias Posts: 35Member

    Sorry, I noticed there's was a cosutomer_id NaN and customerID null in the last screenshot, I fixed the payload:


    But anyway still the same problem, doesn't return the SaleLines.Items from my endpoint after the post, my related problem still.


    Thank you.

  • messhiasmesshias Posts: 35Member

    Hello,


    How's going?


    Any feedback about this subject?


    Thank you.

  • Adrian SamuelAdrian Samuel Posts: 474Moderator, Lightspeed Staff moderator

    Thank you @messhias for the payload. This is expected behaviour.

    To highlight what was said earlier, i'll say this: the Lightspeed Retail API never sent the Item object data in response to a Sale POST request. You always had to individually request that data by making another request using either the itemID to the Item endpoint or the Sale using the saleID endpoint loading the SaleLine.Item relations.

    Adrian Samuel

    API Integrations Consultant - Strategic Solutions

    Lightspeed HQ

  • messhiasmesshias Posts: 35Member

    Ok,


    Thank you.

Sign In or Register to comment.