title: cURL to AngularJS $http.Post
body: <p>I need to perform a Post request. While it's working with Curl in Terminal, I struggle to get it working in AngularJS.</p>
  
  <pre><code>curl -H ‘Content-type: xml’ -XPOST -d@’xmlDoc.xml’ http://localhost:8080/geoserver/wps
  </code></pre>
  
  <p>I tried:</p>
  
  <pre><code>                   $http({
                          method: 'POST',
                          url: 'http://localhost:8080/geoserver/wps/',
                          data: xmlDoc,
                          headers: {'Content-Type': 'application/xml'}
                      }).success(function (data, status, headers, config) {
                        [...]
                      }).error(function (data, status, headers, config) {
                        [...]
                      });
  </code></pre>
  
  <p>and also:</p>
  
  <pre><code>                     $http.post('http://localhost:8080/geoserver/wps', requestXML)
                       .success(function (data, status, headers, config) {
                       [...]
                       }).error(function (data, status, headers, config) {
                       [...]
                       });
  </code></pre>
  
  <p>But the response is always:</p>
  
  <pre><code>    &lt;ows:Exception exceptionCode="NoApplicableCode"&gt;
              &lt;ows:ExceptionText&gt;org.xmlpull.v1.XmlPullParserException: only whitespace content 
      allowed before start tag and not { (position: START_DOCUMENT seen {... @1:1)  
  &lt;/ows:ExceptionText&gt;
  </code></pre>
  
  <p>Do I have to write the curl code into a seperate PHP file and call it from angular?</p>