I have a website which I am trying to make a request via web API to the database. The API basically updates a bit field (in this case from 0 to 1).
Error:
This is all from the console.
OPTIONS http://123.123.123.123:12345/project/webapi.svc/category/api/1/do/something 405 (Method Not Allowed)
send @ jquery-1.12.4.js:10254
ajax @ jquery-1.12.4.js:9738
click @ PageModal.js:10
(anonymous) @ jquery-ui.js:12443
dispatch @ jquery-1.12.4.js:5226
elemData.handle @ jquery-1.12.4.js:4878
XMLHttpRequest cannot load http://123.123.123.123:12345/project/webapi.svc/category/api/1/do/something. Response to page.aspx preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://123.123.123.123' is therefore not allowed access. The response had HTTP status code 405.
Request:
$.ajax({
type: 'POST',
contentType: "application/json; charset=utf-8",
url: "http://123.123.123.123:12345/project/webapi.svc/category/api/1/do/something", //method Name
data: JSON.stringify({ id: ticketId }),
dataType: 'json',
error: function (msg)
{
alert("error: " + msg.status);
}
});
The only thing I can find on this are people who are trying to access the API from a different domain but I am on the same domain. I also have an iOS app which can POST without an issues however it seems the website is having issues.
Question:
How can I fix this 405 error? What is happening here?