title: Using Python requests, can I add "data" to a prepared request?
body: <p>The code below sets up <code>_request</code> if the HTTP method is <code>GET</code>, then it has an <code>if</code>statement for handling <code>PUT</code> <code>POST</code> and <code>PATCH</code>.</p>
  
  <p>I'm trying to have one single request setup statement for all method types.</p>
  
  <p>Is this possible?  It appears to me that there is no way to add <code>data</code> to a prepared request, and if this is true then perhaps I'm stuck with needing two different ways of setting up a request, one way for <code>GET</code> and one way for <code>PUT</code>, <code>PATCH</code> and <code>POST</code>.</p>
  
  <pre><code>def fetch_from_api(self):
          s = Session()
          headers = { "Authorization" : REST_API_AUTHORIZATION_HEADER}
          _request = Request(self.method, self.url_for_api, headers=headers)
  
          if self.method in ['POST', 'PATCH', 'PUT']:
              headers['content-type'] = 'application/x-www-form-urlencoded'
              _request = Request(self.method, self.url_for_api, headers=headers, data=self.postdata)
  
          prepped = _request.prepare()
          self.api_response = s.send(prepped)
  </code></pre>