Having one of those dumb moments, and I can't figure out what's wrong.
I am trying to call a PUT (Web API) command.
Code Snippets:
var person = {
"id": 1
"name": "John",
"age": 25,
"country": Australia
};
var serviceUrl = 'http://myapi/person';
console.log(person);
function updatePerson(id, personObject){
return $http.put(serviceUrl + '/' + id, personObject).then(
function(results){
return results;
});
};
updatePerson(1, person).then(
function(results){
},
function(error){
}
);
Essentially, when I call the above function, I am getting a 400 (Bad Request) error.
Using fiddler, I am noticing that the data being passed (in the TextView tab) is of the form:
id=1&name=John&age=25&country=Australia
Using Postman, where I am defining the raw JSON content as follows:
{
"id": 1
"name": "John",
"age": 25,
"country": Australia
}
The PUT command executes successfully.
And in fiddler, the Textview represented the one which I put as above.
Any advice or ideas on where to debug/look at?
P.S. I just noticed that all of my PUT commands are returning a 400 error (which I've tested before and was working all fine). I am not completely sure what changed in my solution, for all the PUT functions to stop working properly.
Update: in Chrome's console log, I can see that the object is defined as follows:
{id: 1, name: John, age: 25, country: Australia}
which when I paste directly to Postman works fine as well.