Consuming APIs with the new Cloud Orchestrator

Hi @danielvianna

There are two main sources of documentation, mainly due to the fact that the API is not consistent yet between the:

  • on-premise installation of Orchestrator (old API authentication, with the old Authenticate endpoint that uses tenant, username and a password)
  • cloud platform Orchestrator (new API authentication, via the methods from this link).

Unfortunately, that bit of documentation for the Cloud Platform Orchestrator API is more of a workaround (and this is why it is so clunky).

In simple terms though.
This step provides you with all the codes:

You will use the:

Postman example:


With a working body example to start a job with some arguments:

(the release key needs to be discovered first, of course; there is an API call for that too).

  • you will also want to refresh your access_token every 24 hours with this call and your refresh_token (which never expires):

I hope this will make it work for you :slight_smile:

3 Likes

I think you have to remove the square brackets for code challenge in the url.

2 Likes

I have the same issue when trying to execute the post request to fetch the access token:

POST  https://account.uipath.com/oauth/token HTTP/1.1
Content-Type: application/json,

{
    "grant_type": "authorization_code",
    "code": "[Auth Code]",
    "redirect_uri": "https://account.uipath.com/mobile",
    "code_verifier": "[Verifier]",
    "client_id": "5v7PmPJL6FOGu6RB8I1Y4adLBhIwovQN"
}

The answer is:

HTTP/1.1 401 Unauthorized
Server: nginx
Date: Fri, 13 Sep 2019 07:52:47 GMT
Content-Type: application/json
Content-Length: 60
Connection: close
ot-tracer-spanid: 123
ot-tracer-traceid: 123
ot-tracer-sampled: true
X-Auth0-RequestId: 123
X-RateLimit-Limit: 1000000
X-RateLimit-Remaining: 999999
X-RateLimit-Reset: 1568361168
cache-control: private, no-store, no-cache, must-revalidate, post-check=0, pre-check=0, no-transform

{
  "error": "access_denied",
  "error_description": "Unauthorized"
}

There was a strange occurrence: one time it worked, but the next call failed again.

What is wrong? My code or yours?

1 Like

@loginerror

I was able to make it work!!

I believe that what makes it confusing by comparing to other APIs is that :
-There are too many tokens, half of the tasks are done with Bearer Access Token and Bearer ID Token.
-You need to heal that every day with a refresh token
-The documentation and forum posts mix different methods

Suggestions: improve naming conventions, remove documentation that leads to paths that will not work anymore, reduce the number of tokens, if possible remove that refresh token.

If security is a concern why not using 2-factor authentication?

1 Like

@loginerror

New problems:
Everything was working including start job via API, until… I’ve tried Stop Job.

I got this response:

I insisted a little bit and now I got into a new problem, ALL requests except regenerate tokens are dead again aka "it says authentication failed, I am getting variations of these responses despite generating multiple Bearer ID and access tokens with the refresh code:

    "message": "You are not authenticated!",
    "details": "You should be authenticated (sign in) in order to perform this operation

So, basically after trying this step it broke all of my authentication chain for all postman API mockups : 1-Discovering UI PAth Account
2-Getting Service Instance Logical Name
3-Making Orchestrator API Calls
4-Get Jobs Started by Robots
5-Retrieving Robot ID
6-Get Jobs Started by Robot Name
7-Retrieveing Robot ID
8-Retrieving Robot Information According to ID
9-Get Releases Get All
10-Get Jobs - Get
11- Jobs - Stat job with inputs

WHILE BEFORE EVERYTHING WAS WORKING :frowning:

This is super strange. Could you show your postman call?

Hello, if anyone is using Node.js, I’d appreciate some feedback on the experimental support of Cloud Platform OAuth added a couple of weeks back (see the mention of refreshToken in the readme):

There is also a tools folder to get the refresh token without too much pain.

1 Like

I fixed it.
The problem occurred when I downloaded the postman collection template from UiPath and somehow it affected a “production” collection I am using for my project. I erased all pre-defined settings then it works now

2 Likes

This is interesting @qbrandon
I’m trying to build a automated Ci/CD pipeline for API monitoring using Postman’s automated runner (Newman) that doesn’t involve any external application but just pure Postman Collections, to make sure we separate the API from any existing code. Any ideas on that is achievable?

Do we really need a refresh token? so far I have these other API’s in my web application:

-Fedex
-Converge Payment Gateway
-Sendgrid
-Google Gmail

None of them require refresh tokens and all of them use 1 token for authentication only. Why does UIpath need to have so many locks and keys?

Hello, not a heavy user of POSTMAN myself, so I do not know any specific limitation…

Do we really need a refresh token?

Many public services provide the option of using API keys as authentication mechanism to simplify the process. However, with the Cloud Platform, we are in essence exposing an identity management platform on top of our SaaS (at this point basically Orchestrator)
We have plans to offer the possibility of provisioning API key style credentials in Orchestrator to cover similar use cases, but for now only the complete user authentication flow between the Cloud Platform and Orchestrator is necessary, hence the arguably heavy OAuth dance with refresh tokens and access tokens.

Hey @danielvianna

Just to add, I think one of the previous Cloud Platform updates exposed the setting that will allow you to increase the expiration time, see here:
https://docs.uipath.com/releasenotes/docs/august-2019

I didn’t test it myself, but it could already make it simpler.

As to the auto-refresh, I had an Azure LogicApp process that adds queue items to Orchestrator via API and I simply made another process that refreshes my access_token with the refresh_token. If you have a way to run an automated (time scheduled) query with Postman, then that would be the way to go.

1 Like

Awesome… i was looking for such option. Is there a maximum limit for the expiration time ?

I am trying to connect to UIPath from Appian.

went over the link About OData and References

to get all required values required on Appian to establish the connection with UI path.

out of which i need values for below field , which i have it wrongly configured , so getting an error

Required value for : UiPath Public Cloud URL

values tried :
cloud.uipath.com/Infosukpnfid
platform.uipath.com/Infosukpnfid
https://cloud.uipath.com/Infosukpnfid
https://platform.uipath.com/Infosukpnfid

Error : org.apache.http.client.ClientProtocolException

Hi @jganeshbabu

What does the Infosukpnfid stand for?

Hi loginerror,

i have referred the below url for orchestration api:
https://docs.uipath.com/orchestrator/v2019/reference#consuming-cloud-api

i am able to call all the api given there but now, question is now i want to run the process or bot the robot through api.
May i know how to proceed further from here, because for every api i am getting unauthorized error even after using the access token.
Please help.
Regards,
Manish Jawla

Hi Loginerror,
I am done with the above api calls, they are working fine thanks for all the assistance but may i know further procedure to call the rest of the api for trigger the process?
Regards,
Manish Jawla

Hi, Did you find anything regarding this?

Hi @Anderson_Lazzari @harsh497

This blog post might be of use here then :slight_smile:

Quick disclaimer: this is not an official guide from UiPath. The user has clearly put a lot of effort into it though.

Thanks @loginerror, I tried this but could not get it working.

Hi

Follow orchestrator swagger for all possible endpoints and parameters.

To trigger a process:
https://platform.uipath.com/dinesh/dinesh/swagger/ui/index#!/Jobs/Jobs_StartJobs

One of the important parameter for running a job is Release key. you can get the release key with another api endpoint.
https://platform.uipath.com/dinesh/dinesh/swagger/ui/index#!/Releases/Releases_GetReleases

The Postman collection in the below link will also help in understanding and using the endpoints