# Call an Integration Service activity

> 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](declaring-resource-bindings.md).
- An authenticated UiPath CLI (`uip`) session.

:::note
`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

1. List the connector's activities and the object each one maps to:

   ```bash
   uip is activities list uipath-microsoft-outlook365 --output table
   ```

2. Describe the object to get the concrete path for each of its operations:

   ```bash
   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.

:::important
`GETBYID` is the connector's operation kind, not an HTTP verb. Pass `method_name="GET"` to `ActivityMetadata`.
:::

## Call the operation from your function

1. Import `ActivityMetadata` and `ActivityParameterLocationInfo`:

   ```python
   from uipath.platform import UiPath
   from uipath.platform.connections.connections import (
       ActivityMetadata,
       ActivityParameterLocationInfo,
   )
   ```

2. Describe the request and route each input to its location:

   ```python
   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},
   )
   ```

3. Map the connector response onto your `Output` model.

### Result

The SDK substitutes `id` into the path and issues the request:

```
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 |

:::warning
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](accessing-platform-services.md) — other platform resources available at runtime.
- [Testing and debugging](testing-and-debugging.md) — run and debug the function.
