I've a basic Post in angular using $resource
angularFormsAPP.factory('accountService', function ($resource) {
return {
save: function (student) {
return $resource('/api/Account').save(student);
}
}
});
then i have used like this
accountService.save(student).$promise.then(function (data) {
alert('Student saved..');
$location.url("Registrations/Courses");
}, function (error) {
alert('Save student failed-' + error);
});
When I use it in Chrome it works. In IE(11.0.9) however I got a 415 (Unsupported Media Type) error.
The Problem solved. I needed to modify the service call like below:
angularFormsAPP.factory('accountService', function ($resource) {
return {
save: function (student) {
return $resource('/api/Account').save(student, {
headers: { "Content-Type": "application/json" }
});
}
}
});
Or
angularFormsAPP.factory('accountService', function ($resource) {
return {
save: function (student) {
return $resource('/api/Account').save(student, {});
}
}
});
angularFormsAPP.factory('accountService', function ($resource) {
return {
save: function (student) {
return $resource('/api/Account').save(student);
}
}
});
then i have used like this
accountService.save(student).$promise.then(function (data) {
alert('Student saved..');
$location.url("Registrations/Courses");
}, function (error) {
alert('Save student failed-' + error);
});
When I use it in Chrome it works. In IE(11.0.9) however I got a 415 (Unsupported Media Type) error.
The Problem solved. I needed to modify the service call like below:
angularFormsAPP.factory('accountService', function ($resource) {
return {
save: function (student) {
return $resource('/api/Account').save(student, {
headers: { "Content-Type": "application/json" }
});
}
}
});
Or
angularFormsAPP.factory('accountService', function ($resource) {
return {
save: function (student) {
return $resource('/api/Account').save(student, {});
}
}
});
No comments:
Post a Comment