kiwigrid / k8s-sidecar

This is a docker container intended to run inside a kubernetes cluster to collect config maps with a specified label and store the included files in a local folder.
MIT License
613 stars 183 forks source link

try to parse `REQ_PAYLOAD` as json to avoid unexpected quoting #285

Closed fbrousse closed 1 year ago

fbrousse commented 1 year ago

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.

fbrousse commented 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.