title: Angular JS POST request not sending JSON data
body: <p>I am trying to send an object as JSON to my webservice in Flask that is expecting JSON in the request data.</p>
  
  <p>I have tested the service manually by sending JSON data and it works fine. However, when I try to make a http POST request through angular controller, the web server sends me a message saying it did not receive JSON.</p>
  
  <p>When I inspect the request headers in Chrome it appears that data is not being sent in JSON but regular key/value pairs even through the Content Type is set to application/json</p>
  
  <pre><code>Request Method:POST
  Status Code:200 OK
  Request Headersview source
  Accept:application/json, text/plain, */*
  Accept-Encoding:gzip,deflate,sdch
  Accept-Language:en-US,en;q=0.8
  Connection:keep-alive
  Content-Length:49
  Content-Type:application/json;charset=UTF-8
  DNT:1
  Host:localhost:5000
  Origin:http://localhost:5000
  Referer:http://localhost:5000/
  User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36
  X-Requested-With:XMLHttpRequest
  Request Payload
  application=AirFare&amp;d1=10-APR-2013&amp;d2=14-APR-2013
  </code></pre>
  
  <p>If you seen the last line below Request Payload, you can see the data is not in JSON format.</p>
  
  <p>This is the HTTP POST call in my angular controller:</p>
  
  <pre><code>$http({
              url: '/user_to_itsr',
              method: "POST",
              data: {application:app, from:d1, to:d2},
              headers: {'Content-Type': 'application/json'}
          }).success(function (data, status, headers, config) {
                  $scope.users = data.users; // assign  $scope.persons here as promise is resolved here 
              }).error(function (data, status, headers, config) {
                  $scope.status = status + ' ' + headers;
              });
  };  
  </code></pre>
  
  <p>I am sending the data as an object {} but I have tried to send it after serializing by JSON.stringify however, nothing I do seems to send JSON to the server.</p>
  
  <p>Really appreciate if somebody can help out.</p>