Calling Orchestration Api through jquery

Hello,
i am trying to explore for calling through Orchestration Api through jquery from visual studio

Even after passing the required data to authenticate request is showing username and password not provided

$.ajax({
type: “POST”,
url: “https://xxx/api/account/authenticate”,
data:{ “usernameOrEmailAddress” : “xx”,
“password” : “xx”} ,
success: function (response) { alert(response); alert(response.LicenseKey); alert(“sucess”) },
failure: function (response1) {
alert(‘error’);
alert(response1);

        }

    });

Any direction on this will be very helpfull

Thank you

Hi Husein,

I see two issues in your code:

  1. the URL is wrong, it should be something like “https://platform.uipath.com/api/Account
  2. your request is missing the tenant parameter in data, “tenancyName”: “xx”, or “tenancyName”: “default”

Regards
Silviu

Hello,
Than you for your input but
i was just pointing to local orchestration as mentioned in the api guide

Note: All examples have been built using the https://staging.uipath.com Orchestrator address. Please use your own Orchestrator address

After entering tenancy as parameter it seems to be working as fiddler is showing success with “result” attribute showing the key returned by the api

But cannot access the result with jquery
var data = {};

    // throw some data into the object
    //  data.address = '123 Main Street';
    //data.city = 'Orlando';
    //data.state = 'FL';

    data.tenancyName = "xxx",

data.usernameOrEmailAddress = “xxx”,
data.password = “xxx”

    // convert the object into a json string
    var data_json = JSON.stringify(data);

var result = ‘’;
// alert(sendInfo);
//json object passed
$.ajax({
type: “POST”,
url: “xxx/api/account/authenticate”,
data: JSON.stringify(data_json),
dataType: “json”,
contentType: “application/json; charset=utf-8”,
success: function (data) { result = data; alert(result); },
failure: function () {
alert(‘error’);

        }
        
        

    });


    alert('the value:' +result);

is not returning any value

Regards,

The following example is working for me:

$.ajax({
	type: "POST",
	contentType: "application/json",
	url: "https://platform.uipath.com/api/account",
	data: JSON.stringify({ "tenancyName":"xxx", "usernameOrEmailAddress" : "xxx","password" : "xxx"}) ,
	error: function (data) {console.log(data.responseJSON.message); console.log(data);},
	success: function(data) {console.log(data); console.log(data.result);}
    });

Replace the Url, Tenant, Username and Password with real data and give it a try.

1 Like

Actually recently it has
Strangely for me it is neither going in success or error block but in fiddler it is showing as success