Query parms

mikesitmikesit Member Posts: 31
edited September 2018 in Development
Hey guys,

We're  seeing some strange results with query params;  I'm guessing there is a syntax issue but can't seem to find it.

Trying to get all sales (no relations) with a total of $414.04.  SaleId 8 has that value for it's total and it is the only expected result.

When use this URL: https://api.lightspeedapp.com/API/Account/xxxxxx/Sale?completed=true&total=419.04

The response is:
</code></div><code><div><br>&nbsp;&nbsp;&nbsp; An error has occurred and we've been notified.<br>&nbsp;&nbsp;&nbsp; Please try again and if this problem persists please contact support.<br></div>

I don't think any of those query parms require encoding but we tried that anyway and used:
https://api.lightspeedapp.com/API/Account/xxxxxx/Sale?completed%3Dtrue%26total%3D419.04

And the response came back with all orders regardless of their total.

What am I missing?

- rock


3 comments

  • jamesratcliffejamesratcliffe Administrator, Lightspeed Staff Posts: 160 moderator
    @mikesit Unfortunately, you can't use the 'total' field as a filter because it's calculated on the fly for each request.

    The second request returns all sales because it's reading 'completed%3Dtrue%26total%3D419.04' as one long parameter. You often need to encode characters within the parameter names and values, but never encode the = and & characters. Otherwise, the server will ignore them when parsing the URL.

    James Ratcliffe
    Lightspeed HQ
  • mikesitmikesit Member Posts: 31
    edited September 2018
    OK, thanks James...  We'll change our query builder to skip encoding those chars.

    using a different query target this worked just fine:

    https://api.lightspeedapp.com/API/Account/xxxxxx/Sale?completed=true&timeStamp=>%2C2018-08-30T00:00:00-00-00

    NB: Do you have a list of "calculated" properties that cannot be used in filters?

    - rock
    Post edited by jamesratcliffe on
  • jamesratcliffejamesratcliffe Administrator, Lightspeed Staff Posts: 160 moderator
    @mikesit Currently, we don't have a list of the fields that can and can't be used as filters, but we'd like to add it to the documentation in the future.

    Any field beginning with 'calc' can't be used as a filter, and neither can the other total-related fields.
    James Ratcliffe
    Lightspeed HQ
Sign In or Register to comment.