UiPath Documentation
functions
latest
false
Guia do usuário de funções
  • Visão geral
    • Sobre funções
  • Funções do Python
  • Implantar e executar

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.

Pré-requisitos

  • An Integration Service connection for the connector, declared as a binding. See Declare a resource binding.
  • An authenticated UiPath CLI (uip) session.
Observação:

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:

    uip is activities list uipath-microsoft-outlook365 --output table
    uip is activities list uipath-microsoft-outlook365 --output table
    
  2. 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>
    

Resultado

The two commands resolve an activity name to a path. For Get Email By ID:

Nome da AtividadeObjectOperaçãoPath
Get Email By IdMessageGETBYID/hubs/productivity/messages/{id}
Get Email ListMessageGET/messages

The same two commands work for any connector, so this is the general recipe for turning an activity name into an ActivityMetadata definition.

Importante:

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:

    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,
    )
    
  2. 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},
    )
    
  3. Map the connector response onto your Output model.

Resultado

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.

CampoRoutes the input to
path_paramsPlaceholders in object_path, such as {id}
query_paramsThe query string
header_paramsCabeçalhos de solicitação.
body_fieldsThe request body
multipart_paramsMultipart form fields
AVISO:

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.

Próximas Etapas

Esta página foi útil?

Conectar

Precisa de ajuda? Suporte

Quer aprender? Academia UiPath

Tem perguntas? Fórum do UiPath

Fique por dentro das novidades