Query String parameter quirks

Surge777xSurge777x Posts: 6Member
I've noticed some strange issues with query string parameters when trying to find a list of sales within a date range. If i don't have them in a specific order they will bring back every sale our account has ever created. I swap the location of the two time variables then it will pull for the date range.
For example

https://api.lightspeedapp.com/API/Account/{account}/Sale.json?load_relations=["SaleLines"]&offset=0&completeTime=>=,2019-01-01T00:00:00-0600&completeTime=<,2019-01-06T00:00:00-0600&completed==,true

gives me this result

        "count": "127",
        "offset": "0",
        "limit": "100"

which is far too many

I had it working previously with

https://api.lightspeedapp.com/API/Account/{account}/Sale.json?load_relations=["SaleLines"]&offset=0&completeTime=<,2019-01-06T00:00:00-0600&completeTime=>=,2019-01-01T00:00:00-0600&completed==,true

        "count": "7",
        "offset": "0",
        "limit": "100"

which is accurate for the date range

I think it should work regardless of the order, but in these cases it changes depending on the order, and sometimes it works one way and sometimes works the other way.
Tags:

2 comments

  • Michael CareyMichael Carey Posts: 65Administrator, Lightspeed Staff moderator
    edited February 15

    Hello,

    Rather than providing two parameters to get the date range (greater than and less than), you could try using the 'between' operator.

    https://api.lightspeedapp.com/API/Account/{account}/Sale.json?load_relations=["SaleLines"]&offset=0&completeTime=><,2019-01-01T00:00:00-0600,2019-01-06T00:00:00-0600&completed=true
    

    You can read more about the available query operators here: https://developers.lightspeedhq.com/retail/introduction/parameters/#query-operators


    Thanks,

    Michael Carey

    Product Manager
    Lightspeed HQ
  • Surge777xSurge777x Posts: 6Member

    I did find the solution to this issue, using the between operator in the query string instead of greater than and less than

    ><%3E%3CBetween operator. Search values that are within a range. (Example: itemID=><,1,10 would return all itemIDs greater than or equal to 1 and less than or equal to 10)

Sign In or Register to comment.