Closed fbrousse closed 1 year ago
Extract from : https://reqbin.com/code/python/m2g4va4a/python-requests-post-json-example#:~:text=To%20post%20a%20JSON%20to,it%20to%20a%20JSON%20string.
To post a JSON to the server using Python Requests Library, call the requests.post() method and pass the target URL as the first parameter and the JSON data with the json= parameter. The json= parameter takes a dictionary and automatically converts it to a JSON string.
the post method converts the json to string. Here we read from a os.environ and thus a string. So we send a string converted to string. It adds extra quotes and breaks for some server implementation (seen with grafana for provisioning). With the fix here we convert first the payload to dict to get it in the right format.