---
schema_version: "1"
id: 06fef6f4725660ee7084dfbbc6dc14877dcda0573327d5041d7862ac9d1c97bd
title: Anypoint Studio との IDP のインテグレーション
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/idp/integrating-idp-with-anypoint-studio.md
canonical_url: https://docs.mulesoft.com/jp/idp/integrating-idp-with-anypoint-studio
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 63be999c28f638420cd6b64d986bbed0fdb9781a0870758fde9846cc54b6c0c5
description: MuleSoft Documentation Site
latest: true
---
# Anypoint Studio との IDP のインテグレーション

ドキュメントアクションの IDP Runtime Service API Connector を使用して、パブリッシュ済みのドキュメントアクションを Anypoint Studio から実行して結果を取得します。このコネクタは、ドキュメントアクションを Anypoint Exchange にパブリッシュすると自動的に生成されます。Exchange から Mule Connector としてダウンロードできます。

ドキュメントアクションのバージョンごとに異なるコネクタが生成されます。たとえば、ドキュメントアクションを初めてパブリッシュすると、このドキュメントアクションのバージョン ​`1.0.0`​ を実行するコネクタが Exchange に生成されます。その後、ドキュメントアクションを変更してバージョン ​`1.1.0`​ として再パブリッシュすると、別のコネクタが生成されます。この新しいドキュメントアクションバージョンを実行するには、このコネクタをダウンロードして Studio にインストールする必要があります。インテグレーションを構築するときに、この動作を考慮してください。

IDP Runtime Service API Connector には、次の操作があります。

- **getDocumentActionExecution**
    
    ドキュメントアクションの実行結果を取得します。
- **postDocumentActionExecution**
    
    処理するためにドキュメントを IDP に送信します。

## [](#始める前に)始める前に

次の Anypoint 権限があることを確認します。

Execute Published Actions (パブリッシュ済みアクションの実行)

ユーザーがパブリッシュされたドキュメントアクションを実行し、実行結果を取得できるようにします。

すでに接続アプリケーションが IDP 用に設定されている場合、​**「Configure Connected Apps (接続アプリケーションの設定)」**​権限は不要で、新しい接続アプリケーションを作成する代わりに既存の接続アプリケーションを使用できます。

## [](#接続アプリケーションの作成)接続アプリケーションの作成

IDP API と通信するには、次の詳細を使用して接続アプリケーションを作成します。

- Type (種別): `App acts on its own behalf (client credentials) (アプリケーションが自身ために行動する (クライアントログイン情報))`
- Scopes (スコープ): `Execute Published Actions (パブリッシュ済みアクションの実行)`

接続アプリケーションを作成したら、後で使用するために、その ​**ID**​ と​**シークレット**​をコピーしておきます。

詳細は、[接続アプリケーション](https://docs.mulesoft.com/jp/access-management/connected-apps-overview)を参照してください。

## [](#アクセストークンの取得)アクセストークンの取得

接続アプリケーションを設定したら、次の ​`curl`​ コマンドを使用してトークンを取得します。

```bash
curl --location --request POST 'https://anypoint.mulesoft.com/accounts/api/v2/oauth2/token' \ (1)
--header 'Content-Type: application/json' \
--data-raw '{
 "grant_type": "client_credentials",
 "client_id": "<connected-app-client-id>", (2)
 "client_secret": "<connected-app-client-secret>" (3)
}'
```

<table><tbody><tr><td><i class="conum" data-value="1"></i><b>1</b></td><td>EU 地域のユーザーは、​<code>eu1.anypoint.mulesoft.com</code>​ ドメインを使用します。</td></tr><tr><td><i class="conum" data-value="2"></i><b>2</b></td><td><code>&lt;connected-app-client-id&gt;</code>​ を接続アプリケーションのクライアント ID に置き換えます。</td></tr><tr><td><i class="conum" data-value="3"></i><b>3</b></td><td><code>&lt;connected-app-client-secret&gt;</code>​ を接続アプリケーションのクライアントシークレットに置き換えます。</td></tr></tbody></table>

IDP API をコールするときにアクセストークンを使用します。

## [](#idp-runtime-service-api-connector-の設定)IDP Runtime Service API Connector の設定

操作を使用する前に、手動またはグローバル設定要素を使用して、次の値を指定してコネクタを設定します。

- **host**​: Anypoint エンドポイント URL
    
    例: `idp-rt.{region}.anypoint.mulesoft.com`
- **port**​: 接続の HTTP ポート
    
    例: `443`​。
- **basePath**​: プロトコルなしの、コールする URL のベースパス
- **protocol**​: コールのプロトコル (大文字)
    
    例: `HTTPS`
- **Response timeout**​: この操作の応答タイムアウト
- **clientId**​: IDP をコールするための接続アプリケーションのクライアント ID
- **clientSecret**​: IDP をコールするための接続アプリケーションのクライアントシークレット
- **accessTokenUrl**​: 接続アプリケーションのアクセストークンを取得するための URL
    
    例: `[https://anypoint.mulesoft.com/accounts/api/v2/oauth2/token](https://anypoint.mulesoft.com/accounts/api/v2/oauth2/token)`

## [](#idp-へのドキュメントの送信)IDP へのドキュメントの送信

**postDocumentActionExecution**​ 操作を使用して、ドキュメントを IDP に送信し、対応するドキュメントアクションバージョンを実行します。

コネクタの ​**\[Postdocumentactionexecution request data (Postdocumentactionexecution 要求データ)\]**​ 項目で要求の詳細を指定します。サンプル要求を次に示します。

```bash
%dw 2.0
output multipart/form-data
---
{
   parts : {
   	 callback : {
   	 	  headers : {
               "Content-Type" : "text/plain"
               },
           content : '{"noAuthUrl": "https://{yourCallbackURL}.com"}'
       },
       file : {
           headers : {
               "Content-Disposition" : {
                   "name": "file",
                   "filename": "{myFile.jpg}",
                   "subtype": "form-data"
                   },
               "Content-Type" : "image/jpg"
               },
           content : payload
           }
       }
}
```

この操作からの応答には、実行結果を取得するために使用する必要がある実行 ID が含まれています。

## [](#実行結果の取得)実行結果の取得

**getDocumentActionExecution**​ 操作を使用して、実行 ID を指定してドキュメントアクションの実行結果を取得します。

この操作からのサンプル応答を見やすく短縮したものを次に示します。

```linenums
{
    "id": "d68e099e-8d37-4188-905a-0eac68b7bf61",
    "documentName": "invoice-1.jpg",
    "status": "SUCCEEDED",
    "pages": [
        {
            "page": 1,
            "fields": {
                "invoiceDate": {
                    "value": "1 June, 1983"
                },
                "invoiceNumber": {
                    "value": "8248"
                }
                ...

            },
            "tables": {
                "table1": [
                    {
                        "unitPrice": {
                            "value": ""
                        },
                        "price": {
                            "value": "$ 198.00"
                        }
                        ...
                    }
                ]
            },
            "prompts": {
                "business": {
                    "prompt": "what is the company main business",
                    "source": "document",
                    "answer": {
                        "value": null
                    }
                }
            }
        }
    ]
}
```

## [](#関連情報)関連情報

- [事前作成済みのスキーマを使用したドキュメントの分析](https://docs.mulesoft.com/jp/idp/creating-document-actions)
- [ドキュメントアクションのパブリッシュ](https://docs.mulesoft.com/jp/idp/publishing-document-actions)