2

I've been looking for hours for some angularjs documentation that explains how to POST xml data using the $http object. Does angular simply not offer it with their $http object? The code:

$http({ 
  method: 'POST',
  url: 'http://10.0.0.123/PHP/itemsGet.php',
  data: '<searchKey id="whatever"/>',
  headers: { "Content-Type": 'application/x-www-form-urlencoded' }
})

2 Answers 2

2

I came here looking for the same thing, however I tried Skyler's solution and it did not work. I changed the content type to 'application/xml' and it worked. Here is the snippet:

$http({ 
    method: 'POST',
    url: 'http://10.0.0.123/PHP/itemsGet.php',
    data: '<searchKey id="whatever"/>',
    headers: { "Content-Type": 'application/xml' }
})
Sign up to request clarification or add additional context in comments.

3 Comments

"I tried Skyler's solution and it did not work. I changed the content type to 'application/xml' and it worked" Changing the content type to application/xml IS Skyler's solution.
ok, now I look like a crazy person because I posted my answer before Skyler changed the answer to xml
He didn't change it to xml. Unfortunately the posted code was the "before" code, but the solution has always been "Seemed that application/xml made more sense"
1

Figured it out. The Content-Type is threw me for a while. Seemed that application/xml made more sense. Oh well, whatever works!

$http({ 
    method: 'POST',
    url: 'http://10.0.0.123/PHP/itemsGet.php',
    data: '<searchKey id="whatever"/>',
    headers: { "Content-Type": 'application/xml' }
})

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.