Inventory Transfer JSON Response Missing Fields?

gregaricangregarican Member Posts: 926 

I have an automated routine running that's been in place for about a year now. It ports in everything from inventory to customers to sales to refunds to vendors to transfers to employees each day. The API transfer response from last night failed to port in successfully. Since I am looking for the key data fields in the response and this one had a missing element.

I'll paste the API response below. Note that the sentOn field isn't provided. Even if it's a null value, shouldn't this element be passed back? Looking at the API documentation ( it still appears in there. Seems to be many inconsistencies and workarounds in what should be standard API without gotchas. Another example is an element that can be an array. When there are multiple items in the element then it's passed back as an array. When there is a single item, then it's not passed back as an array with a single item. It's passed back as a singleton that isn't an array type. But I digress :) Anyone have feedback about this missing element?

{"Transfer": {

 "transferID": "1930",

 "note": "",

 "archived": "false",

 "timeStamp": "2019-05-09T13:04:15-04:00",

 "createTime": "2019-05-09T13:04:06-04:00",

 "status": "open",

 "needBy": "2019-05-09T17:00:00-04:00",

 "sendingShopID": "3",

 "sentByEmployeeID": "0",

 "receivingShopID": "1",

 "createdByEmployeeID": "33"



  • gregaricangregarican Member Posts: 926 

    Usually when an API response is unexpected somehow I look in the web client to see what it looks like. In this case the Transfer 1930 appears to be invalid. In that the sending site didn't even have the item on-hand. The transaction was allowed to be saved, and I'm assuming that's why the sentOn was N/A. Since there wasn't a quantity to send. Screen shots attached.

    Regardless, if the transaction was allowed to be saved in the web client, shouldn't the sentOn be passed back in the API response as null?

  • gregaricangregarican Member Posts: 926 

    Just pinging this for any feedback from the Lightspeed Retail API team...

  • gregaricangregarican Member Posts: 926 
  • gregaricangregarican Member Posts: 926 
  • [Deleted User][Deleted User] Posts: 0

    Hi @gregarican,

    Let me check this, I'll update you as soon as possible.

  • gregaricangregarican Member Posts: 926 

    So any feedback? Since apparently the Community board is the primary place to seek API support, I am looking forward to the good word :)

  • gregaricangregarican Member Posts: 926 

    Pinging this again.

  • gregaricangregarican Member Posts: 926 

    Not saying this is necessarily the case, although sometimes I feel like it :(

  • [Deleted User][Deleted User] Posts: 0

    Hello @gregarican,

    I apologize for the really long delay from my part. If the Transfer hasn't been sent in the UI, is by design that the field sentOn will not be present in the response. Once the transfer is sent to its destination the field sentOn will be included in the response.

  • gregaricangregarican Member Posts: 926 
    edited May 2019

    Thanks for getting back to me. While I can understand a null value being the case when the record was created on the web client front-end, an API should consistently pass back all fields. Regardless of their values being provided or not. Hence the null.

    A basic hypothetical example would be a customer endpoint. Say there's a first name, middle initial, and last name field. While the majority of records might not have a middle initial value, the API consumer would still be looking for all three fields in the API response. Even if null. Like this dummy response below:

    { customer:

    { first_name: "Joe",

    middle_initial: null,

    last_name: "Schmoe"}


    Otherwise any custom API code by a consumer has to account for previously-unknown gotchas, since the JSON structure being returned could differ due to the inconsistency.

  • [Deleted User][Deleted User] Posts: 0

    Hi @gregarican,

    You have a valid point, that why I brought this to our Product Manager attention, I can't warranty that this behaviour will change, but they're aware of this, if this gets implemented I will let you know.

  • maurisourcemaurisource Partner Posts: 35 partner


    +1 @gregarican on this. It would be nice that the API returns the field even when it's empty. Instead, it hides it from the Json response. This sometimes break my code now and then with this error in PHP:

    ErrorException : Undefined index:

    So as a workaround, I have to wrap isset() statement in PHP around every possible field that can be unset in the response! This is undeniably time-consuming.. 😩

Sign In or Register to comment.