- 入门指南
- Swagger 定义
- Orchestrator API 使用示例
使用 Cloud API
UiPath Automation Cloud 存在两种使用 API 的机制:
- 从 Automation Cloud 获取 API 访问权限信息(如本页面所述)
- 注册外部应用程序以使用 OAuth 流程(信息和说明)。
要使用哪种机制?您可以使用所需的任何机制,但如果您的 Automation Cloud 组织使用 Azure Active Directory 模型,则您必须在 Automation Cloud 中注册外部应用程序并使用 OAuth 流程。
以前通过 API 或使用 PowerShell 和其他脚本工具连接到 Orchestrator CE 的所有客户端现在都需要更新,以便连接到 UiPath Automation Cloud。
未更改私有云中安装的 On-premises Orchestrator 或 Orchestrator。连接到这些 Orchestrator 实例时,您可以像以前一样继续使用 API 集成、PowerShell 或其他脚本工具。
通过 Automation Cloud 帐户中的“服务”页面,您可以访问每个现有服务的 API 特定信息,从而通过 API 调用轻松找到向基于云的 Orchestrator 服务进行身份验证所需的信息。
- 登录到您的 Automation Cloud 帐户。
- 导航到“管理”>“租户”。“租户”页面会列出所有现有租户。
- 单击所需租户左侧的箭头以显示其可用服务。
- 单击 Orchestrator 服务的“API 访问”。“API 访问”窗口将打开,其中包含以下特定于服务的信息:
- “用户密钥”- 使您能够生成用于 API 或第三方应用程序的唯一登录密钥,以便代表您执行登录和操作。以前称为刷新令牌。
- 组织 ID - 您的组织名称。这是基本 URL 之后的名称。
- “租户名称”- 租户的显示名称。
-
客户端 ID - 特定于 Orchestrator 应用程序本身,对于特定平台上的所有用户和租户均相同。例如,https://cloud.uipath.com 上的所有租户都具有相同的客户端 ID 值。
不要关闭此窗口。您需要该信息才能进行身份验证调用。通过单击在每个字段旁边的“复制”按钮 复制值。
https://account.uipath.com/oauth/token
发送 POST 请求。请求和响应应如以下示例所示:
发布
https://account.uipath.com/oauth/token
请求标头
密钥 |
值 |
---|---|
授权 |
承载 |
请求正文
{
"grant_type": "refresh_token",
"client_id": "{client_ID}",
"refresh_token": "{user_key}"
}
{
"grant_type": "refresh_token",
"client_id": "{client_ID}",
"refresh_token": "{user_key}"
}
响应代码
200 OK
响应正文
{
"access_token": "{access_token}",
"id_token": "{id_token}",
"scope": "openid profile email offline_access",
"expires_in": 86400,
"token_type": "Bearer"
}
{
"access_token": "{access_token}",
"id_token": "{id_token}",
"scope": "openid profile email offline_access",
"expires_in": 86400,
"token_type": "Bearer"
}
{tenant_name}
、{client_ID}
和 {user_key}
值。
{access_token}
以备后用。
{access_token}
在 24 小时内有效。您必须使用 {refresh_token}
重新生成 {access_token}
;否则,您将收到 401 状态代码。
-
向
https://cloud.uipath.com/{organizationName}/{tenantName}/orchestrator_/odata/Settings/UiPath.Server.Configuration.OData.GetLicense
执行 GET 请求 -
将
{organization_name}
和{tenant_name}
替换为“API 访问权限”页面中的值。 -
将“授权”标头设置为
Bearer {access_token}
,并粘贴在上述过程中收到的{access_token}
值。
发送请求后,您应该会从 Orchestrator 收到响应,其中包含此服务的许可证信息。
请求和响应应如以下示例所示:
获取
https://cloud.uipath.com/{organizationName}/{tenantName}/orchestrator_/odata/Settings/UiPath.Server.Configuration.OData.GetLicense
请求标头
密钥 |
值 |
---|---|
授权 |
承载 |
响应代码
200 OK
响应正文
{
"@odata.context": "https://cloud.uipath.com/{organizationName}/{tenantName}/orchestrator_/odata/$metadata#UiPath.Application.Dto.License.LicenseDto",
"HostLicenseId": null,
"Id": 0,
"ExpireDate": 1622678399,
"GracePeriodEndDate": 1622678399,
"GracePeriod": null,
"AttendedConcurrent": false,
"DevelopmentConcurrent": false,
"StudioXConcurrent": false,
"LicensedFeatures": [],
"IsRegistered": true,
"IsExpired": false,
"CreationTime": "2019-11-28T06:16:21.373Z",
"Code": "d1c8-4785-55ace9a0c233",
"Allowed": {
"Unattended": 1,
"Attended": 1,
"NonProduction": 0,
"Development": 1,
"StudioX": 0
},
"Used": {
"Unattended": 0,
"Attended": 0,
"NonProduction": 0,
"Development": 1,
"StudioX": 0
}
}
{
"@odata.context": "https://cloud.uipath.com/{organizationName}/{tenantName}/orchestrator_/odata/$metadata#UiPath.Application.Dto.License.LicenseDto",
"HostLicenseId": null,
"Id": 0,
"ExpireDate": 1622678399,
"GracePeriodEndDate": 1622678399,
"GracePeriod": null,
"AttendedConcurrent": false,
"DevelopmentConcurrent": false,
"StudioXConcurrent": false,
"LicensedFeatures": [],
"IsRegistered": true,
"IsExpired": false,
"CreationTime": "2019-11-28T06:16:21.373Z",
"Code": "d1c8-4785-55ace9a0c233",
"Allowed": {
"Unattended": 1,
"Attended": 1,
"NonProduction": 0,
"Development": 1,
"StudioX": 0
},
"Used": {
"Unattended": 0,
"Attended": 0,
"NonProduction": 0,
"Development": 1,
"StudioX": 0
}
}
初始授权后的所有 Orchestrator API 调用都必须转到 Orchestrator URL。
它们必须包含以下标头:
- Authorization: Bearer {access_token}
- X-UIPATH-OrganizationUnitId: {FolderId}
请注意,对于 Automation Cloud Orchestrator 服务,API 请求显示的结果将限制为每页 1,000 个条目。
$top
和 $skip
参数来检索后续页面。例如,使用 GET https://cloud.uipath.com/{organizationName}/{tenantName}/orchestrator_/odata/RobotLogs?$top=1000&$skip=2000
请求检索 2,001 到 3,000 之间的机器人日志条目。