On-site API not returning valid XML or ZIP?

ob1ob1 Member Posts: 5
I've downloaded Lightspeed OnSite 2018 2.02 demo (https://www.lightspeedhq.co.uk/pos/onsite/downloads/) and successfully installed it on macOS High Sierra 10.13.

I'm attempting to use Python to retrieve products using:

r = requests.get(PRODUCTS_URL, params={'count': 1, 'offset': 0}, verify=False)

This works successfully:

r.status_code == 200
r.headers == {'Date': 'Tue, 17 Jul 2018 12:55:59 GMT', 'Content-Length': '10004', 'Content-type': 'application/zip', 'Server': 'LightSpeedServer/20181.0.0 client_version/2802 rest_protocol/1.0.0'}
r.text == 'PKkwh6HAMPkzvCkgycicvJtf9y2VjhayiZNRWeoFNP4AXm0jZ1aOivLemypdRA56sqEX6e' (snipped)

I was expecting an XML document, however according to the headers (and the prefix of the content returned) I'm receiving a ZIP file - which is unexpected but should be able to be overcome by attempting to unzip the contents of whatever `r.content` contains - however, using the system zip tool or Python's zipfile module - neither considers the archive valid (nor fixable).

Upon further analysis it looks like a base64 (give or take) encoded response with a magic marker prefix and attempting to take `r.data[4:]` and decode it using base64 yields a more reasonably sized reply, but still fails to get recognised as a zip archive even when prepending the first four bytes (or two bytes) of the response.

How do I get the system to return either XML as documented or how do I interpret the response to get the product data?


  • jamesratcliffejamesratcliffe Administrator, Lightspeed Staff Posts: 160 moderator
    It looks like you're receiving an encrypted response because you didn't send the private app ID in the X-PAPPID header.
    James Ratcliffe
    Lightspeed HQ
Sign In or Register to comment.