Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

9
  • 1
    Good catch - I saw your application/json in GET and somehow missed that you hadn't provided it on the request. You may also need to make sure that you return something from POST or you might get a 500. Commented Mar 31, 2012 at 4:01
  • Doesn't seem to be necessary. When I print r, I get <Response [200]>. Commented Apr 1, 2012 at 5:36
  • How do I retrieve this json at the server side ? Commented Feb 15, 2013 at 12:01
  • 11
    Little heads up before using json.dumps here. The data parameter of requests works fine with dictionaries. No need for converting to a string. Commented Jul 2, 2018 at 6:32
  • 2
    @lolololol ol It's necessary. You are setting an argument for the function/method you're calling. In this case the function/method is named post(). The left side of the assignment operator = is the parameter name some dev defined (e.g. def post(some_param0, headers, ...):). The righthand side of the assignment operator (i.e. assignment value) is the variable you defined (e.g. headers = { ... }) that also just happens to be called headers in this example. You could rename the right side of the assignment (e.g. the assignment value) to whatever you like! Commented Jul 2, 2023 at 21:50