Image Upload API giving dishonest errors

meatcomputermeatcomputer Member Posts: 24
Hello, I am in the midst of writing a program which interfaces with the lightspeed api.
Everything has been going smoothly so far until today when I tried to use the image uploading functionality of the API as described here https://developers.lightspeedhq.com/retail/endpoints/Image/
Upon trying to test the system using the provided python code I get errors saying that my image exceeds 8MB, the image I was testing with is less than 10kb so I'm clearly getting an erroneous error message.
Here is my code

<div>def upload_image_to_lightspeed():<br></div><div>&nbsp;&nbsp;&nbsp; url = '<a rel="nofollow" href="https://api.lightspeedapp.com/API/Account/'+lightspeed_account_id+'/Image.json" title="Link: https://api.lightspeedapp.com/API/Account/'+lightspeed_account_id+'/Image.json">https://api.lightspeedapp.com/API/Account/'+lightspeed_account_id+'/Image.json</a>'<br></div><div>&nbsp;&nbsp;&nbsp; files = {'image': ('testimage.jpg', open("/home/meatcomputer/Desktop/avatar.jpg", "rb")<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; , 'image/jpeg')}<br></div><div>&nbsp;&nbsp;&nbsp; payload = {<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "description": "Test Image",<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "ordering": 1,<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "itemID":222<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br></div><div><br></div><div>&nbsp;&nbsp;&nbsp; r = requests.post(url, files=files, data=payload, headers=headers)<br></div><div>&nbsp;&nbsp;&nbsp; return r<br></div><div><br></div>


Why am I getting this error message and what can I do to address it?
Sign In or Register to comment.