I have the following POST method in my Web API Controller:
[HttpPost]
public async Task<IHttpActionResult> Post(Hotspot hotspot)
{
try
{
int id = await SomeMethod();
return Ok(id);
}
catch (ArgumentException e)
{
return BadRequest(e.Message);
}
}
And then I make the POST request and try to get the id:
var hotspots = $resource('/api/adminhotspots', { save: { method: 'POST' } });
hotspots.save($scope.hotspot).$promise.then(function (id) {
console.log(id);
});
Unfortunately, I get a $promise object. My console shows:
m
$promise : d
$resolved : true
I can check that the server sends the parameter correctly in the Network tab in my Developer Console. And it is correct, indeed.
Why doesn't the $resource catch the parameter and what can I do about it?
Thank YOU!