title: Handling form data with flask request
body: <p>I am using <code>flask-restful</code> as an api server and am constructing the first <code>PUT</code> method.  Using request imported from flask, I am able to access <code>request.form</code> data without issue with the following cURL command:</p>
  
  <pre><code>curl http://127.0.0.1:5000/api/v1/system/account -X PUT -d username=asdas -d email=asdasd@test.com
  </code></pre>
  
  <p>My <code>PUT</code> method logs out both the username and email without issue:</p>
  
  <pre><code>def put(self):
      print 'SystemAccountPut'
      print request.form['username']
      print request.form['email']
      return
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>SystemAccountPut
  asdas
  asdasd@test.com
  </code></pre>
  
  <p>I have an app using the <a href="https://github.com/mzabriskie/axios" rel="nofollow">axios project</a> to make api calls.  When axios attempts to <code>PUT</code> form data, <code>request.form</code> no longer works.  Here is the call axios is making converted to cURL command from Chrome Dev Console:</p>
  
  <pre><code>curl 'http://127.0.0.1:5000/api/v1/system/account' -X PUT -H 'Pragma: no-cache' -H 'Origin: http://127.0.0.1:5000' -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: en-US,en;q=0.8' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36' -H 'Content-Type: application/json;charset=UTF-8' -H 'Accept: application/json, text/plain, */*' -H 'Cache-Control: no-cache' -H 'Referer: http://127.0.0.1:5000/settings' -H 'Connection: keep-alive' --data-binary '{"username":"asdas","email":"asdasd@test.com"}' --compressed
  </code></pre>
  
  <p>With the same method above <code>request.form['username']</code> and <code>request.form['email']</code> are empty.  <code>request.data</code> however has the form data in it, and <code>request.get_json()</code> also will output the form data in JSON format.</p>
  
  <p>My question is what should I be using in this case to retrieve the form data? The first curl command is clean with <code>request.form</code> having the data I need, but <code>request.data</code> is empty.  The second cURL command leaves <code>request.form</code> broken but does populate <code>request.data</code>.  Is there a best practice on how I should retrieve form data in both cURL cases? </p>