I have a restful api that works normally when i am calling from the postman. On postman i am giving the following configuration to get answer: -POST: "https://www.example.net/API/MyFunction" I have no authorization. -Headers: Content-Type : application/json, username:myusername, password:mypassword -Body raw
{"firstparameter":"firtparameter_value"}
I have a pure html domain where i would like to make some calls and provide data from this api. So i added a link to the jquery-3.3.1.js and create an ajax call. I tried to follow this guide https://www.html5rocks.com/en/tutorials/cors/ but when i run the call i am getting the bellow error. Ajax call:
var username = 'myusername';
var password = 'mypassword';
$.ajax({
type: 'POST',
dataType: "jsonp",
url: 'https://www.example.net/API/MyFunction',
contentType: 'text/plain',
crossDomain: true,
data:{"firstparameter":"firtparameter_value"},
xhrFields: {
withCredentials: false
},
headers: {
username: username,
password: password
},
success: function () {
error: function () {
}
});
the error i am geting is :
GET https://www.example.net/API/MyFunction/?callback=jQuery33104247946565223606_1541427224545&firstparameter=firtparameter_value&_=1541427224546 net::ERR_ABORTED 405 (Method Not Allowed)