Orchestrator API Call - Invalid Credentials

Hi everyone,

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);}
1 Like

Hi can you indicate Orchestrator version you have installed?

Hi dokumentor,

We use Orchestrator v2020.4.2

Try changing:
request.withCredentials = false;

You are sending credentials in the body so you are not supposed to indicate credentials in header

Thanks for the suggestion. I still get the same error though.
Please see attached error screencap.

Can you provide URL? Have you checked tenancyName indicated is correct?

We only have one tenant - the default. I’m using basic authentication so I’m sending request to /api/account/authenticate/

You may have to check full URL address if it is correct. Check this related post:

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.