Data Service API - Part 1 | Getting Started

Hello Community,

In this video we’ll get started with the Basics of UiPath Data Service APIs. The video covers the following fundamental concepts:

  1. Register an External Application by defining scopes and Redirect URLs in the UiPath Automation Cloud and get an App ID
  2. Understand a few basics of the OAuth 2.0 Authorization with PKCE protocol
  3. Use the Postman API client to make an authorization call using PKCE and fetch an API token
  4. Place a call to read Entity data from UiPath Data Service using the api token

NOTE: Basic familiarity with UiPath Data Service is required for this video

Reference topics referenced in the video:

  1. UiPath Data Service User Guide - https://docs.uipath.com/data-service/docs
  2. UiPath Data Service API documentation home page - Data Service - API Access
  3. The Postman UiPath Connector guide- UiPath Add-ins Guide
  4. Open source PKCE generator - Online PKCE Generator Tool
  5. Advanced Automation Template with DataService - RPA Component | UiPath Marketplace | Overview from RPA Vanguard
  6. The Postman Callback URLs: UiPath Add-ins Guide

cc: @Karan @Vibhor.Shrivastava @ankit.saraf

2 Likes

This is fantastic @AndyMenon :clap: :clap:
Thanks for sharing this with the community!

1 Like

@AndyMenon ,
Thanks for this article. I’ve tried following the steps in the video, but when I click the Get New Access Token button in PostMan, I get an error in the UiPath login box that just says “Error. An unknown error has occurred (#200)”. Any ideas what to check/fix?

–BillR

Hello @Bill_Richardson ,

That’s a strange error indeed. Maybe one or more of the parameters in the request may be off. Is it possible to send me a screen shot of your Postman request?

thank you for taking the time to engage with my channel! :slight_smile:
-Andy

Thinking about this:
Are you getting an error after you login to the UiPath login box presented to you after you hit the Get New Access token button? To me it looks like the login to the UiPath Authorization end point failed because the Username or password is incorrect.

Can you please confirm by logging in separately via the automation cloud using an new Incognito Browser window?

thanks

@AndyMenon ,
Thanks for the reply. I figured it out. I had the wrong redirect-uri in the External Application. I was using browser-based PostMan, so I needed the browser redirect-uri, but I had the desktop redirect-uri. With that fixed, it worked.

–BillR

1 Like

Excellent!
Thanks for the update.

:grinning:

I’m having the same problem, I’m using postman on the desktop Callback URL is correct and still with error 200

Hi @Bill_Richardson , Im struggling to generate auth token to connect to Data service api. What is the redirect url you have given while connecting from UiPath studio

Hi @Ana_Patricia ,

I have never connected to the UiPath Data Service API using HTTP Request calls from Studio. I imagine it would be similar to how I’ve done calls to get refresh tokens, retrieve data, etc. in other tools such as Alteryx.

Within Studio, I just use the UiPath.DataService.Activities:
image

But if you were trying to connect to an instance of Data Service that wasn’t in your tenant, you would have to do it with API calls.

I was not able to get a redirect url to work when calling from Alteryx, so I used a technique of manually generating the first refresh token using PostMan (which lasts 60 days, I believe), and then using that refresh token to continue to request new refresh tokens as needed. I always stored the latest refresh token in a permanent file so I could use it to get another one. As long as I request another refresh token within 60 days, I’m set to keep going. If the refresh token on file expires, I have to manually get a new token/refresh token with PostMan.

Once you have a refresh token, you can request new refresh tokens with it easily using a POST to

https://cloud.uipath.com/identity_/connect/token
with grant_type=refresh_token, client_id, client_secret, and refresh_token as the payload.

I’m sure there are better solutions and maybe even an easy way to handle a redirect url in Studio, so if anyone else wants to jump in and add to this, I’d be interested.

Hello @Ana_Patricia ,

I have added this link in the description of the video, but will reproduce it here again:

This page contains the links for the call back URLs you can use for Postman.

Thanks,
Andy

Thanks for the detailed explanation Bill. So if we follow this approach, what do we have to give in external application redirect url if using from studio? or does it not matter if we use refresh token.

Also even to generate refresh token we need access token right? So, is there any method to get access token from UiPath http activity as we have a requirement not to use anyother applications like post man o generate one.

@Ana_Patricia ,

Yes, if you can come up with a scheme whereby you are using refresh tokens all the time, you don’t need a redirect uri.

Unfortunately, I was unable to find a way to get an initial token without the redirect uri. I’m pretty sure a method for this exists and hoping someone more versed in the UiPath API for Data Service jumps in here to explain how to do it. --BillR

Hi @Bill_Richardson ,

That’s right. We are given the first api access token via the redirect URI.
We then use the access token to fetch the first refresh token.
We then set up a system where in we initialize our process with this refresh token saved to a repository

If we end up using that refresh token then we get another token to replace it and the process repeats.

On a related note, this was covered in Part 2 of the video I posted in my OP above.

thanks

1 Like