Hi there!!,
We need to launch a robot from the orchestrator by clicking a button inside an aspx website.
How do I make an API call and launch a robot from there?
@josesgar
The calls are done by submitting JSON requests to your server. Here’s a link example to start a job:
https://your.server.here/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs
do you have more details about this?
where do I find the releaseKey? do you have an example?
@josesgar https://your.server/odata/Releases
You can also just go to https://your.server.here/odata to get a list of everything
Thank you for sharing, do you have documentation about authenticating and getting tentant?
Right!
When you say “run the javascript code in the browser”, what do you mean?
@josesgar you can make a JSON post asynchronysly to https://your.server.her/api/account/authenticate
Here’s a C# example of how I authenticate in a desktop app. The principals for any app are the same, only the language would be different:
string token = "";
string myJson = "{'tenancyName': 'YOUR_TENANT_NAME','usernameOrEmailAddress': 'YOUR_LOGON_ACCOUNT','password': 'YOUR_PASSWORD'}";
using (var client = new HttpClient())
{
var response = await client.PostAsync(
"https://YOUR.SERVER.HERE/api/account/authenticate",
new StringContent(myJson, Encoding.UTF8, "application/json"));
toolStripTextBox1.Text = "Result: " + response.ReasonPhrase;
if (response.ReasonPhrase == "Bad Request")
{
toolStripTextBox1.ToolTipText = response.Content.ReadAsStringAsync().Result;
MessageBox.Show(toolStripTextBox1.ToolTipText = response.Content.ReadAsStringAsync().Result, "Bad Request", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
var items = response.Content.ReadAsStringAsync().Result.TrimStart('{').TrimEnd('}').Replace("\"", String.Empty).Split(',');
foreach (var entry in items)
{
if (entry.Split(':')[0] == "result")
{
token = "Bearer " + entry.Split(':')[1]; <========GETS TOKEN
}
}
The token
that you get is then passed to any JSON requests you make to the orchestrator, i.e.:
myJson = "{'startInfo':{'ReleaseKey':'YOUR-RELEASE-KEY-GOES-HERE','Strategy':'Specific','RobotIds':[YOUR_ROBOT_ID],'NoOfRobots':YOUR_NO_ROBOTS,'Source':'Manual'}}";
client.DefaultRequestHeaders.Add("Authorization", token); <=========USE TOKEN HERE
response = await client.PostAsync(
"https://YOUR.SERVER.HERE/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs",
new StringContent(myJson, Encoding.UTF8, "application/json"));
You have a URL there , copy the entire code and run it after opening that URL , I mean, if you open the URL in browser, it will ask you to paste the code and run it after pasting @josesgar
thank you for answering! how do I connect without tenant id? I am using Community edition
I got it!!
I can make API Calls to jobs from Community orchestrator using a tenant:
- Create an account in platform “https://platform.uipath.com/”
- Register a tenant associated with email you connected “UiPath”
So… I have a problem, the orchestrator is directing me to the login page when I connect to a service I think that the 2 accounts are missmatching
Can you check login into that URL once and then open the URL as