title: Python Requests POST doing a GET?
body: <p>I am using Python 2.7.5, Django 1.7, requests 2.4.1, and doing some simple testing. However, it seems like when I call requests.post, the method is doing a GET instead.</p>
  
  <p>My code, talking to a RESTful API. Note that the POST command works via Hurl.it with this payload and endpoint:</p>
  
  <pre><code>def add_dummy_objective(self):
      """
      To the bank
      """
      payload = {
          'displayName': {
              'text': self._test_objective
          },
          'description': {
              'text': 'For testing of API Middleman'
          },
          'genusTypeId': 'DEFAULT'
      }
      obj_url = self.host + self.bank_id + '/objectives/?proxyname=' + self._admin_key
      req = requests.post(obj_url, data=json.dumps(payload), headers=self.headers)
      return req.json()
  </code></pre>
  
  <p>I am setting the headers to json:</p>
  
  <pre><code>self.headers = {
      'Content-Type'  : 'application/json'
  }
  </code></pre>
  
  <p>Instead of creating a new objective (as expected with a POST), I get a list of objectives back (what I would expect with a GET). Using pdb, I see:</p>
  
  <pre><code>(Pdb) req.request
  &lt;PreparedRequest [GET]&gt;
  (Pdb) req.request.method
  'GET'
  </code></pre>
  
  <p>How did this get flipped? I have used the Python requests library before with no issues, so I'm not sure if I am missing something obvious or if (with newer versions of Django / Requests) I have to set another parameter? Is this a caching issue? Any tips for debugging? I have tried re-installing requests, and rolling back Django to 1.6.5, but nothing works...must be simple. -- Thanks!</p>
  
  <p>====== UPDATE 1 ========</p>
  
  <p>Just consolidating some of the debug info that Martijn suggested here:</p>
  
  <pre><code>(Pdb) requests.post.__name__
  'post'
  </code></pre>
  
  <p>Stepping into the requests/api.py > post() definition:</p>
  
  <pre><code>(Pdb) l
   88         :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.
   89         :param \*\*kwargs: Optional arguments that ``request`` takes.
   90         """
   91         import pdb
   92         pdb.set_trace()
   93  -&gt;     return request('post', url, data=data, **kwargs)
  </code></pre>
  
  <p>Drilling down into the request() method:</p>
  
  <pre><code>(Pdb) method
  'post'
  (Pdb) l
   43           &gt;&gt;&gt; req = requests.request('GET', 'http://httpbin.org/get')
   44           &lt;Response [200]&gt;
   45         """
   46         import pdb
   47         pdb.set_trace()
   48  -&gt;     session = sessions.Session()
   49         return session.request(method=method, url=url, **kwargs)
  </code></pre>
  
  <p>One more layer, in session.request:</p>
  
  <pre><code>(424)request()
  -&gt; method = builtin_str(method)
  (Pdb) method
  'post'
  (Pdb) l
  419             :param cert: (optional) if String, path to ssl client cert file (.pem).
  420                 If Tuple, ('cert', 'key') pair.
  421             """
  422             import pdb
  423             pdb.set_trace()
  424  -&gt;         method = builtin_str(method)
  425
  426             # Create the Request.
  427             req = Request(
  428                 method = method.upper(),
  429                 url = url,
  </code></pre>
  
  <p>Stepping down to the end of the method, where the request is actually made, my "prep" is a POST, but my resp is a GET:</p>
  
  <pre><code>(Pdb) prep
  &lt;PreparedRequest [POST]&gt;
  (Pdb) n
  -&gt; return resp
  (Pdb) resp
  &lt;Response [200]&gt;
  (Pdb) resp.request
  &lt;PreparedRequest [GET]&gt;
  (Pdb) l
  449                 'allow_redirects': allow_redirects,
  450             }
  451             send_kwargs.update(settings)
  452             resp = self.send(prep, **send_kwargs)
  453
  454  -&gt;         return resp
  455
  456         def get(self, url, **kwargs):
  457             """Sends a GET request. Returns :class:`Response` object.
  458
  459             :param url: URL for the new :class:`Request` object.
  </code></pre>