I’m trying to create a script to make API calls to our on-premise orchestrator in Node.js. My issue is that when I send my credentials to the authenticator URL, I get a status code 400 (error code 1000) back - “invalid credentials”.
The credentials I’m using are definitely correct; I can use them to log into Orchestrator normally. Also, if I send the exact same credentials using the UiPath WebAPI HTTP request, I get authenticated fine.
Can anyone think of what might be the issue? Code snipped attached:
var XMLHttpRequest = require(“xmlhttprequest”).XMLHttpRequest;
var request = new XMLHttpRequest();
var post_data = JSON.stringify({
“tenancyName”:“Default”,
“usernameOrEmailAddress”:"<>",
“password”:"<>"
});
request.open("POST","<<URL>>",true);
request.withCredentials = true;
request.setRequestHeader("Content-Type", "application/json; charset=utf-8");
console.log("About to send");
request.send(post_data);
console.log("Sent successfully, waiting for response");
request.onload = () => {
const obj = JSON.parse(request.responseText);
if (request.status == 200){
var access = obj.access_token;
console.log("Created access token");}
else
console.log("Error at request send: "+request.responseText);}
Cheers for the link. I’m still getting issues though. I have double checked the URL, it is the same as my Orchestrator home. Again, putting those login details exactly into UiPath HTTP request gains authentication successfully, so I’m wondering if it’s something in my JS that I’m not doing right.