- Overview
- Python functions
- Deploy and run
Call a connector operation from a Python function with invoke_activity, and resolve the object path behind a Studio activity name using the UiPath CLI.
Studio activity names such as Get Email By ID are labels on a connector object and operation. Python has no equivalent lookup by activity name, so a function calls the underlying operation directly through connections.invoke_activity, describing the request with ActivityMetadata.
Prerequisites
- An Integration Service connection for the connector, declared as a binding. See Declare a resource binding.
- An authenticated UiPath CLI (
uip) session.
sdk.connections.retrieve() returns connection metadata only, such as the id, base URI, and folder. It does not call the connector. invoke_activity calls retrieve internally, so both are not needed.
Resolve the object path for an activity
-
List the connector's activities and the object each one maps to:
uip is activities list uipath-microsoft-outlook365 --output tableuip is activities list uipath-microsoft-outlook365 --output table -
Describe the object to get the concrete path for each of its operations:
uip is resources describe uipath-microsoft-outlook365 Message \ --connection-id <connection-id>uip is resources describe uipath-microsoft-outlook365 Message \ --connection-id <connection-id>
Result
The two commands resolve an activity name to a path. For Get Email By ID:
| Activity name | Object | Operation | Path |
|---|---|---|---|
| Get Email By ID | Message | GETBYID | /hubs/productivity/messages/{id} |
| Get Email List | Message | GET | /messages |
The same two commands work for any connector, so this is the general recipe for turning an activity name into an ActivityMetadata definition.
GETBYID is the connector's operation kind, not an HTTP verb. Pass method_name="GET" to ActivityMetadata.
Call the operation from your function
-
Import
ActivityMetadataandActivityParameterLocationInfo:from uipath.platform import UiPath from uipath.platform.connections.connections import ( ActivityMetadata, ActivityParameterLocationInfo, )from uipath.platform import UiPath from uipath.platform.connections.connections import ( ActivityMetadata, ActivityParameterLocationInfo, ) -
Describe the request and route each input to its location:
sdk = UiPath() payload = sdk.connections.invoke_activity( activity_metadata=ActivityMetadata( object_path="/hubs/productivity/messages/{id}", method_name="GET", content_type="application/json", parameter_location_info=ActivityParameterLocationInfo( path_params=["id"], ), ), connection_id=OUTLOOK_CONNECTION_KEY, activity_input={"id": message_id}, )sdk = UiPath() payload = sdk.connections.invoke_activity( activity_metadata=ActivityMetadata( object_path="/hubs/productivity/messages/{id}", method_name="GET", content_type="application/json", parameter_location_info=ActivityParameterLocationInfo( path_params=["id"], ), ), connection_id=OUTLOOK_CONNECTION_KEY, activity_input={"id": message_id}, ) -
Map the connector response onto your
Outputmodel.
Result
The SDK substitutes id into the path and issues the request:
GET /elements_/v3/element/instances/{connectionId}/hubs/productivity/messages/{id}
GET /elements_/v3/element/instances/{connectionId}/hubs/productivity/messages/{id}
The instances segment carries the connection id, not the elementInstanceId from the connection metadata.
Routing inputs with parameter_location_info
Each field of ActivityParameterLocationInfo names the keys of activity_input that belong in one part of the request.
| Field | Routes the input to |
|---|---|
path_params | Placeholders in object_path, such as {id} |
query_params | The query string |
header_params | Request headers |
body_fields | The request body |
multipart_params | Multipart form fields |
An input that is not listed in parameter_location_info is dropped without an error. A misspelled key surfaces as a missing parameter in the connector response, not as a failed call.
Connector responses vary by version. The same record can arrive as a bare object, wrapped in a list, or inside an items envelope, and field names can follow either the provider's shape or a flattened connector shape. Read the fields you need defensively rather than assuming one shape.
Next steps
- Accessing platform services — other platform resources available at runtime.
- Testing and debugging — run and debug the function.