Question:
I need to POST a JSON from a client to a server. I’m using Python 2.7.1 and simplejson. The client is using Requests. The server is CherryPy. I can GET a hard-coded JSON from the server (code not shown), but when I try to POST a JSON to the server, I get “400 Bad Request”.Here is my client code:
Best Answer:
Starting with Requests version 2.4.2, you can use thejson=
parameter (which takes a dictionary) instead of data=
(which takes a string) in the call:If you have better answer, please add a comment about this, thank you!
Source: Stackoverflow.com
Leave a Review