I am currently facing a challenge with my AngularJS and .NET WebAPI integration. While I can retrieve content or objects successfully through the WebAPI, I am encountering difficulties when attempting to POST data.
When trying to post the content, I receive the following errors:
OPTIONS http://localhost:18130/api/Products XMLHttpRequest cannot load
http://localhost:18130/api/Products. Response for preflight has invalid HTTP status code 405
It's worth noting that when using Fiddler to post, everything works perfectly without any issues.
Below is the AngularJS code snippet I'm utilizing for posting:
var data = { "Title": $scope.title, "Description": $scope.description };
$http.post(
'http://localhost:18130/api/Products',
JSON.stringify(data), {
headers: {
'Content-Type': 'application/json; charset=UTF-8'
}
}).success(function (data) {
console.log(data);
});
Could someone kindly point me in the right direction? The WebAPI and AngularJS app reside on separate domains—is this a CORS issue? How can I resolve this problem when performing posts?
Thank you in advance.