UiPath Documentation
functions
latest
false
Functions ユーザー ガイド
  • 概要
    • 関数について
  • Python の関数
  • デプロイして実行する

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.

前提条件

  • 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

  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>
    

結果の

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

アクティビティ名オブジェクト操作パス
メールを ID で取得MessageGETBYID/hubs/productivity/messages/{id}
メールのリストを取得MessageGET/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

  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.

結果

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.

フィールドRoutes the input to
path_paramsPlaceholders in object_path, such as {id}
query_paramsThe query string
header_params要求ヘッダー
body_fieldsThe request body
multipart_paramsMultipart 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.

次のステップ

このページは役に立ちましたか?

接続

ヘルプ リソース サポート

学習する UiPath アカデミー

質問する UiPath フォーラム

最新情報を取得