What I’m trying to do:
I’m trying to send a POST JSON payload to an external API (Garmin InReach Swagger UI). The response is seemingly non-JSON :
HttpErrorStatus: Invalid JSON in response
at /libanvil/anvil/http.py:63called from set_track_status, line 40called from Form1, line 34
What I’ve tried and what’s not working:
I’m currently sending a dict using anvil.http.request with the “json=True” tag - that is getting the desired data through to the API, but returning the above error. I obviously need to send my data without the json=True tag, but everything else I’ve tried (JSON dumps, writing a json as a string with triple quotes) throws an error 500.
Can’t figure out how to pass anvil.http.request a JSON payload that doesn’t require json=True in the request line.
Code Sample:
def set_track_status(imei, status,interval):
IMEI = str(imei)
Interval=str(interval)
payload_dict = {"Devices": [{"IMEI": IMEI,"Tracking":status,"Interval": Interval}]}
resp = anvil.http.request(url="https://eur-origin.explore.garmin.com:443/ipcinbound/V1/Tracking.svc/Tracking",
method="POST",
data=payload_dict, json=True, username="username",password="password")
return resp
Clone link:
share a copy of your app