Forum Discussion
Power BI Query - post api request for authenticating and then make api calls
Hi,
I'm currently working on UiPath report. API is provided by UiPath to retrive data. It involve 2 steps,
1. Authenticating, using refresh token and client id.
2. API call to get datd using token from step 1.
My query as follows but it does not working
let
token_url = "https://account.uipath.com/oauth/token",
api_base_url = "https://platform.uipath.com/AGC/AGC/odata/OrganizationUnits",
body="grant_type=refresh_token&client_id=8DEv1AMNXxxxxxxxxx&refresh_token=BIrTRLxxxxxxxxxx",
Source = Json.Document(Web.Contents(token_url,
[
Headers = [#"Content-Type"="application/json", #"X-UIPATH-TenantName"="AGC"],
Content=Text.ToBinary(body)
]
)
),
token = Source[access_token],
data= Json.Document(Web.Contents(api_base_url, [Headers=[#"Authorization"="Bearer "&token, #"Content-Type"="application/json", #"X-UIPATH-TenantName"="AGC"]]))
in
dataIs there anything wrong with above query?
UiPath provide documentation on how to get data using API https://docs.uipath.com/orchestrator/reference/consuming-cloud-api
Any solution or suggestion will be helpful.
Thanks,
Ranjith
- Anonymous6 years ago
Thanks Greg...
Just now I get it worked.
The worked query as follows
let token_url = "https://account.uipath.com/oauth/token", api_base_url = "https://platform.uipath.com/AGC/AGC/odata/OrganizationUnits", body="grant_type=refresh_token&client_id=8DEv1AMNXczW3yxxxxxxxxx&refresh_token=BIrTRL7Sqc73ul6M5pEW_xxxxxxxxxxxxxx", Source = Json.Document(Web.Contents(token_url, [ Headers = [#"Content-Type"="application/x-www-form-urlencoded", #"X-UIPATH-TenantName"="AGC"], Content=Text.ToBinary(body) ] ) ), token = Source[access_token], data= Json.Document(Web.Contents(api_base_url, [Headers=[#"Authorization"="Bearer "&token, #"Content-Type"="application/json", #"X-UIPATH-TenantName"="AGC"]])) in dataAnd also I set Credentials to 'Anonymous' and Privacy to 'Public'. It worksπ
2 Replies
- Greg_DecklerCommunity ChampionPlease define "not working"
- AnonymousNot applicable
Thanks Greg...
Just now I get it worked.
The worked query as follows
let token_url = "https://account.uipath.com/oauth/token", api_base_url = "https://platform.uipath.com/AGC/AGC/odata/OrganizationUnits", body="grant_type=refresh_token&client_id=8DEv1AMNXczW3yxxxxxxxxx&refresh_token=BIrTRL7Sqc73ul6M5pEW_xxxxxxxxxxxxxx", Source = Json.Document(Web.Contents(token_url, [ Headers = [#"Content-Type"="application/x-www-form-urlencoded", #"X-UIPATH-TenantName"="AGC"], Content=Text.ToBinary(body) ] ) ), token = Source[access_token], data= Json.Document(Web.Contents(api_base_url, [Headers=[#"Authorization"="Bearer "&token, #"Content-Type"="application/json", #"X-UIPATH-TenantName"="AGC"]])) in dataAnd also I set Credentials to 'Anonymous' and Privacy to 'Public'. It worksπ