UiPath Platform Python HTTP Client
The `uipath-platform` library provides a low-level HTTP client for programmatic access to the UiPath Platform. It is an OpenAPI-generated client exposing various platform APIs like Orchestrator (assets, queues, processes), Data Service, and Automation Cloud. The current version is `0.1.28`. While it has its own release cycle, it is closely related to the main `uipath-python` SDK, which extracted its platform module into this library.
Common errors
-
ModuleNotFoundError: No module named 'uipath_platform'
cause The `uipath-platform` library is not installed in your Python environment.fixRun `pip install uipath-platform` to install the library. -
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url:
cause The provided authentication token is invalid, expired, or lacks the necessary permissions for the requested API endpoint.fixGenerate a new API token with appropriate scopes from your UiPath Automation Cloud tenant's API Access page. Ensure the token is prefixed with `Bearer ` when used. -
TypeError: UipathPlatform.__init__ missing 1 required positional argument: 'organization_id'
cause Required authentication parameters like `organization_id`, `tenant_id`, or `auth_token` were not provided to the `UipathPlatform` constructor.fixEnsure `organization_id`, `tenant_id`, and `auth_token` are explicitly passed to the `UipathPlatform` constructor. It's recommended to use environment variables for these values.
Warnings
- breaking The `uipath-platform` library was extracted from the main `uipath-python` SDK in `uipath-python` v2.9.0. If you are using the `uipath-python` SDK pre-2.9.0, the platform client was integrated; post-2.9.0, it is expected as a separate dependency, potentially leading to import or dependency conflicts if not managed correctly.
- gotcha The `uipath-platform` PyPI package follows its own `0.1.x` versioning scheme, which is distinct from the `2.x.x` versioning of the main `uipath-python` SDK. This can lead to compatibility issues if not carefully considered, as the SDK might expect a specific version of the underlying platform client.
- gotcha Authentication with the UiPath Platform requires providing `organization_id`, `tenant_id` (for tenant-specific operations), and a valid `auth_token`. Misconfigured or missing credentials are a common source of connection errors and `401 Unauthorized` responses.
Install
-
pip install uipath-platform
Imports
- UipathPlatform
from uipath_platform import UipathPlatform
Quickstart
import os
from uipath_platform import UipathPlatform
# Retrieve credentials from environment variables
# Ensure these are set in your environment before running:
# UIPATH_ORGANIZATION_ID, UIPATH_TENANT_ID (optional for some calls), UIPATH_AUTH_TOKEN
# Example: export UIPATH_ORGANIZATION_ID="your_org_id"
# export UIPATH_TENANT_ID="your_tenant_id"
# export UIPATH_AUTH_TOKEN="Bearer your_token_string"
ORGANIZATION_ID = os.environ.get("UIPATH_ORGANIZATION_ID", "")
TENANT_ID = os.environ.get("UIPATH_TENANT_ID", "")
AUTH_TOKEN = os.environ.get("UIPATH_AUTH_TOKEN", "")
BASE_URL = os.environ.get("UIPATH_BASE_URL", "https://cloud.uipath.com")
if not (ORGANIZATION_ID and AUTH_TOKEN):
print("Error: Missing UIPATH_ORGANIZATION_ID or UIPATH_AUTH_TOKEN environment variables.")
print("Please set them before running this script.")
exit(1)
try:
# Initialize the client
# The client object provides access to various operation groups (e.g., assets, queues).
client = UipathPlatform(
organization_id=ORGANIZATION_ID,
tenant_id=TENANT_ID,
auth_token=AUTH_TOKEN,
base_url=BASE_URL
)
print(f"Successfully initialized UiPath Platform client for Organization ID: {ORGANIZATION_ID}")
print("Attempting to list first 5 assets (requires Asset Read permission on your token)...")
# Example: List assets from Orchestrator
# This call requires 'x_uipath_tenantid' for Orchestrator operations.
# Ensure your AUTH_TOKEN has the necessary scopes, e.g., 'Orchestrator.Assets.Read'.
assets_response = client.assets.get_assets(
organization_id=ORGANIZATION_ID,
x_uipath_tenantid=TENANT_ID,
top=5
)
if assets_response.status_code == 200:
print(f"Successfully retrieved assets: {assets_response.parsed}")
else:
print(f"Failed to retrieve assets. Status: {assets_response.status_code}, Error: {assets_response.content}")
except Exception as e:
print(f"An error occurred: {e}")