Hi Clarizen,
I've been trying to access the API through JavaScript, but I can't seem to authenticate. I've never used an API authentication before, so any help is welcome.
I have managed to get the server definition, which does not seem to require authentication, but trying to authenticate I run into the following error: The request has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
I have to use JavaScript for this, any suggestion how to work around the fact that you cannot change the header?
function ajaxPost(url, callback) {
var req = new XMLHttpRequest();
req.open("POST", url, false,'user.name','password123');
req.withCredentials=true;
req.addEventListener("load", function () {
if (req.status >= 200 && req.status < 400) {
callback(req.responseText);
} else {
console.error(req.status + " test " + req.statusText + " " + url);
}
});
req.addEventListener("error", function () {
console.error("Erreur réseau avec l'URL " + url);
});
req.send(null);
}
ajaxPost("https://api2.clarizen.com/v2.0/services/authentication/login", function(reponse) {
var resultat = JSON.parse(reponse);
console.log("ServerDefinitionResponse"+resultat +" & JSON :" + reponse);
});
Thank you for any help,
Noémie Neyron