Does anyone know how to add or create a custom HTTP header using JavaScript or jQuery?
i am using below code but it is giving me 405 Method not Allowed. i am using POST Method but in Request Method but its showing me OPTION in Request Method. Status Code:405 Method not Allowed, when i am using postman it is working and showing me 200 ok status code. does anyone help me what is the issue is going on. i am using below code in HTML.
$(document).ready(function () {
$.ajax( {
url: 'http://api.XXXXXXXXXX.com/SharedServices/SharedData.svc/rest/Authenticate',
data: {
"ClientId": "ApiIntegration",
"UserName": "XXXXX",
"Password": "XXXXX@123",
"EndUserIp": "192.168.1.10"
},
method: 'POST',
dataType: 'json',
headers: {
"contentType": "application/json",
"cache-control": "no-cache"},
success: function (response) {
console.log(response);
},
});
})
what will be correct jQuery code, if there is an issue in my code. here is the screenshot of postman witch i am using.

"cache-control": "no-cache"— Why are you trying to set that on a request header?!