i want to know what is REST API endpoint URL for Uipath in sep 2021 somewhere it i showing cloud. uipath somewhere it is showing platform.uipath
Welcome to our UiPath community.
Earlier it was https://platform.uipath.com
After introducing cloud Orchestrator it was changed to https://cloud.uipath.com
Hi @Milind_kamat,
If you want to know all the endpoints for different calls. You can append /swagger to your cloud/On-Premises orchestrator. It allows you to quickly test out your cases and then later you can replicate it in any HTTP request tool.
For example my cloud orchestrator API endpoints can be accessed like so:
https://cloud.uipath.com/%USERGUID%/%USERSDefaultFolderName%/swagger
All REST API calls one can do the same way ?
import requests
import json
client_id = “8DEv1AMNXczW3y4U15LL3jYf62jK93n5”
user_key = “lC2eQiHo4RHxs0qbb_M_MuF95LB3KgAyKy4pph53wqn6o”
ServiceName = ‘mkspjimr’
AccountName = ‘MKSPJIMR’
class CommunityOrchestratorAPI:
def init(self, client_id, user_key, ServiceName, AccountName):
self.ServiceName = ServiceName
self.AccountName = AccountName
self.client_id = client_id
self.user_id = user_key
self.token = “”
self.robot_ID = “”
self.process_ID = “”
def getUserToken(self):
url = r"https://account.uipath.com/oauth/token"
user_data = f"""{{"grant_type": "refresh_token",
"client_id": "{self.client_id}",
"refresh_token": "{self.user_id}"
}}"""
data = requests.post(url, json=json.loads(user_data),
headers={"X-UIPATH-TenantName": f"{self.AccountName}",
"Content-Type": "application/json"})
authentication_data = json.loads(data.text)
self.token = "Bearer " + str(authentication_data["access_token"])
return
def getProcessID(self, process_name):
process_data = requests.get(f"https://platform.uipath.com/{self.AccountName}/{self.ServiceName}/odata/Releases?$filter=Name eq '{process_name}'",
headers={"Authorization": self.token,
"X-UIPATH-TenantName": f"{self.ServiceName}",
"Content-Type": "application/json"})
process_json = json.loads(process_data.text)
# print(json.dumps(process_json, indent=2))
self.process_ID = process_json["value"][0]["Key"]
return
def getRobotID(self, robotName):
robot_name = requests.get(f"https://platform.uipath.com/{self.AccountName}/{self.ServiceName}/odata/Robots?$filter=Name%20eq%20'{robotName}'",
headers={"Authorization": self.token,
"X-UIPATH-TenantName": f"{self.ServiceName}",
"Content-Type": "application/json"})
robot_json_obj = json.loads(robot_name.text)
self.robot_ID = robot_json_obj["value"][0]["Id"]
return
def runJob(self):
start_job_json = """{ "startInfo":
{ "ReleaseKey": \"""" + self.process_ID + """\",
"Strategy": "Specific",
"RobotIds": [ """ + str(self.robot_ID) + """ ],
"Source": "Manual",
"InputArguments": "{}"
}
}""" # InputArguments should be left {} or not included if workflow does not accept any input
start_job_data = requests.post(f"https://platform.uipath.com/{self.AccountName}/{self.ServiceName}/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs",
json=json.loads(start_job_json), headers={"Authorization": self.token,
"X-UIPATH-TenantName": f"{self.ServiceName}",
"Content-Type": "application/json"
})
return start_job_data
if name == “main”:
client_id = “Client ID”
user_key = “User Key”
ServiceName = ‘Service Name’
AccountName = ‘Account Name’
orchestrator_obj = CommunityOrchestratorAPI(client_id, user_key, ServiceName, AccountName)
orchestrator_obj.getUserToken()
orchestrator_obj.getProcessID(“Process_Name”)
orchestrator_obj.getRobotID(“Robot Name”)
orchestrator_obj.runJob()
KeyError Traceback (most recent call last)
in
73 AccountName = ‘Account Name’
74 orchestrator_obj = CommunityOrchestratorAPI(client_id, user_key, ServiceName, AccountName)
—> 75 orchestrator_obj.getUserToken()
76 orchestrator_obj.getProcessID(“Process_Name”)
77 orchestrator_obj.getRobotID(“Robot Name”)
in getUserToken(self)
30
31 authentication_data = json.loads(data.text)
—> 32 self.token = "Bearer " + str(authentication_data[“access_token”])
33 return
34
KeyError: ‘access_token’
75 orchestrator_obj.getUserToken() How to get rid of this error ?
where can i get tutorial of this new method of calling API using Oen data model way consuming API f Uipath in Python scripts ?
