Okay, guys. I located the problem a line in my header had ( ’ ) instead of ( " ).
Here’s the code:
urlAuth = "https://account.uipath.com/oauth/token"
data = {
"grant_type": "refresh_token",
"client_id": clientID,
"refresh_token": userKey
}
header = {
"Content-Type": "application/json",
"X-UIPATH-TenantName": tenantName
}
r = requests.post(urlAuth, data, header)
response = json.loads(r.content)
auth = "Bearer " + response["access_token"]
I know that now I have to call Folders first, to get my FolderId that corresponds to “X-UIPATH-OrganizationUnitId”.
Then, I have to call Releases, to get the Id of my target process which corresponds to ‘ReleaseKey’.
Finally, I need to call UiPath.Server.Configuration.OData.StartJobs to launch the job I want. Nothing very complicated.
However, I can’t call the endpoint Folders. The documentation is awful. Here’s all informations I have about Folders to show you what I mean by “awful” ![:slight_smile: :slight_smile:](https://emoji.discourse-cdn.com/twitter/slight_smile.png?v=12)
I got the Folder call information here :
This is Folder doc in API doc :
Note that the URL is not the right one. And the authorization is marked SEPARATE from the header.
Moreover, it is not specified if the authorization is a JSON, nor the key, if it is a String, if it contains keywords, its format…
Then I search information by my-self :
https://docs.uipath.com/orchestrator/v0/reference/folders-requests
This is what I get, 2 end point that don’t correspond at all to what I’m looking for, nor to what the API doc shows. In addition, this time we have information about the authorization which is probably a String, remember well.
Finally, I looked at the sample code from the video (Start UiPath Process from Python (Script Code REST API) | Python call UiPath Job - YouTube), which doesn’t really explain how to get the release key for the process he wants to launch. However in his code he has an example of the authorization token:
headers2 = { "Content-Type" : "application/json",
"X-UIPATH-TenantName" : "YOUR TENANTNAME",
"Authorization" : auth}
So here the authorization is IN the header.
So you understand my suffering trying to understand the Uipath API.
Help me to launch a simple process (call of Folders, then Releases, then UiPath.Server.Configuration.OData.StartJobs) and I will put in this post the complete and very simple python code so that other people in my situation will have a quick and easy to understand solution.
Thank you so much,
Regards.