We are trying to create a ticket via jQuery but came across with the following error:
Error: XMLHttpRequest for http://itsmapdv.bmc.com:8008/jwt/login required Cross Origin Resource Sharing (CORS).
Code:
function getAuthorisationCode(pstrUsername, pstrPassword) {
//Get the auhorisation code from the server. We accept the user name and the password, and return the code.
console.log("Starting GetAuthorization");
var xmlhttp;
xmlhttp = new XMLHttpRequest();
//Define a POST request. Notice I set the last parameter to false, which means it goes out synchronously. I need this as I need
//to wait until I get the code before moving on.
xmlhttp.open("POST", "http://itsmapdv.bmc.com:8008/jwt/login", false);
//Add a HTTP header to request to specify the content-type.
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
//Send the request. The POST body is included here.
xmlhttp.send("username=" + pstrUsername + "&password=" + pstrPassword); //Failing here
console.log(xmlhttp.responseText);
//If we get HTTP200 back we're done and we can return the code.
if (xmlhttp.status == 200) {
return "AR-JWT " + xmlhttp.responseText;
}
}
How can we make this CORS call here?