This question has been answered severeal time on this site but none of them are helping. So I ask again:
When I make a POST request like this :
var sectionTypeVM = new Object();
sectionTypeVM.SectionTypeId = 0;
sectionTypeVM.Name = $scope.message;
$http({
method: 'POST',
url: 'http://mtapi.azurewebsites.net/api/sectiontype',
dataType: 'json',
data: sectionTypeVM,
headers: { 'Content-Type': 'application/json; charset=UTF-8' }
}).success(function (data) {
alert(data);
}).error(function (data) {
alert(data);
});
it works perfectly fine, but when I try to do something like this:
$http({
method: 'POST',
url: 'http://mtapi.azurewebsites.net/api/sectiontype',
dataType: 'json',
data: $scope.message,
headers: { 'Content-Type': 'application/json; charset=UTF-8' }
}).success(function (data) {
alert(data);
}).error(function (data) {
alert(data);
});
it doesn't. Why I need to create a separate object the javascript way and send it, why my angularJS object cannot be posted directly (they look same ) ? Is it a server side error or what ? A explanation will be helpful.