> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Service REST メソッドの作成

> ファイルをケースにエクスポートするための Pega Service REST POST メソッドを構築します。サービスパッケージを作成し、PegaAPI ロールを追加して、レスポンス条件を定義します。

まず、サービスパッケージを作成します。

1. 左側の **Records** タブをクリックし、**Integration Resources** を展開して **Service Package** を右クリックし、ショートカットメニューから **Create** コマンドを選択します。
2. **Create Service Package** フォームで、**Service Package Name** フィールドに *customapi* と入力します。**Short description** フィールドにパッケージの説明を入力し、**Create and open** をクリックします。
3. **Edit Service Package** フォームで、**Service access group** フィールドにアクセスグループを指定します (グループの形式は *\<Application\_name>:\<Access group>* です) 。
   **注:** 使用可能なアクセスグループの一覧を表示するには、左側の **Records** タブをクリックし、**Security → Access Group** に移動します。
4. **Save** をクリックします。

次に、ユーザーが Web API にアクセスできるように、アクセスグループに新しいロールを追加します。

1. **Records → Security → Access Group → ABBYYFC:Administrators/ABBYYFC:Users** をクリックして、新しく作成したアクセスグループに移動します。
2. **Available roles** フィールドに *PegaRULES:PegaAPI* ロールを追加します。

次に、新しいサービスを作成します。

1. 左側の **Records** タブをクリックし、**Integration-Services** を展開して **Service REST** を右クリックし、ショートカットメニューから **Create** コマンドを選択します。
2. 開いたフォームで、次の項目を指定します。
   * Service name: *files*
   * Service package name: *customapi*
   * URI Template: *cases/\{id}/files/\{name}*
   * Service version: *v2*
3. **Create and open** をクリックします。
4. **Service** タブをクリックし、**Pega class** フィールドに *Pega-API-CaseManagement* と入力します。次に、**URL path parameters** セクションで、**Id** パラメーターの **Map to Key** 列に *Param.CaseId* と入力します。続けて、**name** パラメーターに *Param.FileName* と入力します。
5. **Methods** タブをクリックします。POST メソッドを展開し、**Request** タブの **Message data** フィールドで次のように指定します。
   * Description: *Request Data*
   * Map to: *Clipboard*
   * Map to key: *Param.Request*
6. <a id="response" />**Response** タブをクリックし、3 つのレスポンス条件を作成します。

<table width="100%">
  <thead>
    <tr>
      <th>
        <p>
          <strong>処理対象</strong>
        </p>
      </th>

      <th>
        <p>
          <strong>パラメーター値</strong>
        </p>
      </th>

      <th>
        <p>
          <strong>ヘッダーフィールド</strong>
        </p>
      </th>

      <th>
        <p>
          <strong>Message data</strong>
        </p>
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        <p>
          <strong>pxIsInternalError</strong>
        </p>
      </td>

      <td>
        <ul>
          <li>
            条件: <em>When</em>
          </li>

          <li>
            When名: <em>pxIsInternalError</em>
          </li>

          <li>
            コンテンツタイプ: <em>application/json</em>
          </li>

          <li>
            ステータスコード: <em>Param.StatusCode</em>
          </li>
        </ul>
      </td>

      <td> </td>
      <td> </td>
    </tr>

    <tr>
      <td>
        <p>
          <strong>pxIsErrorResponse</strong>
        </p>
      </td>

      <td>
        <ul>
          <li>
            条件: <em>When</em>
          </li>

          <li>
            When名: <em>pxIsErrorResponse</em>
          </li>

          <li>
            コンテンツタイプ: <em>application/json</em>
          </li>

          <li>
            ステータスコード: <em>Param.StatusCode</em>
          </li>
        </ul>
      </td>

      <td> </td>

      <td>
        <ul>
          <li>
            説明: <em>Response</em>
          </li>

          <li>
            マッピング元: <em>Clipboard</em>
          </li>

          <li>
            マッピング元キー: <em>Param.Response</em>
          </li>
        </ul>
      </td>
    </tr>

    <tr>
      <td>
        <p>正常時のレスポンス</p>
      </td>

      <td>
        <ul>
          <li>
            条件: <em>Default</em>
          </li>

          <li>
            コンテンツタイプ: <em>application/json</em>
          </li>

          <li>
            ステータスコード: <em>Param.StatusCode</em>
          </li>
        </ul>
      </td>

      <td>
        <ul>
          <li>
            名前: <em>location</em>: マッピング元: <em>Clipboard</em>; マッピング元キー: <em>Param.Location</em>
          </li>

          <li>
            名前: <em>etag</em>; マッピング元: <em>Clipboard</em>; マッピング元キー: <em>Param.eTag</em>
          </li>
        </ul>
      </td>

      <td>
        <ul>
          <li>
            説明: <em>Response</em>
          </li>

          <li>
            マッピング元: <em>Clipboard</em>
          </li>

          <li>
            マッピング元キー: <em>Param.Response</em>
          </li>
        </ul>
      </td>
    </tr>
  </tbody>
</table>

<Warning>
  サービスメソッドのURLが次のとおりであることを確認してください: *[https://Server\&#95;Name/prweb/PRRestService/customapi/v2/cases/\&#123;id\&#125;/files/\&#123;name\&#125](https://Server\&#95;Name/prweb/PRRestService/customapi/v2/cases/\&#123;id\&#125;/files/\&#123;name\&#125);.* そうでない場合、ユーザーがファイルをPegaにエクスポートしようとすると、コネクタは
  エラーを返します。
</Warning>
