> ## 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.

# API を使用したデータの取得

> BatchState および BatchRouting のエントリ ポイント、GET リクエスト、PowerShell の CSV スクリプトを使用して、ABBYY FlexiCapture から Business Process Reporting データを取得します。

<div id="path-to-the-business-process-reporting-data-storage">
  ## Business Process Reporting データストレージへのパス
</div>

エントリポイント:

```text theme={null}
/Reporting/BatchState/List
/Reporting/BatchState/File/<filename>
/Reporting/BatchState/View
/Reporting/BatchRouting/List
/Reporting/BatchRouting/File/<filename>
/Reporting/BatchRouting/View
```

データストレージへのフルパスは、変更可能なリンクです。

例:

```text theme={null}
http://localhost/Flexicapture12/Server/Reporting/BatchState/View
```

ABBYY FlexiCapture 認証モジュール経由でアクセスする場合、リンクに `/FCAuth` が追加されます。

認証済みアクセスは、次の場合に許可されます。

* 認証された ABBYY FlexiCapture ユーザーの場合。
* SAML/JWT トークンを使用する場合。

例:

```text theme={null}
http://localhost/Flexicapture12/Server/FCAuth/Reporting/BatchState/View
```

テナントがデフォルトのものでない場合、`?Tenant=<tenant name>` パラメーターがリンクに追加されます。

例:

```text theme={null}
http://localhost/Flexicapture12/Server/FCAuth/Reporting/BatchState/View?Tenant=myTenant
```

<div id="create-requests">
  ## リクエストを作成する
</div>

受け付けられるのは GET リクエストのみです。

* **List** は、ファイル名の一覧を JSON 形式で返します。
* **File** は、指定した名前のファイルを返します (名前は URL 形式でエンコードされている必要があります) 。
* **View** は、ファイル名の一覧を HTML 形式で返し、前述の **File** コマンドを使用してファイルへのリンクを挿入します。したがって、このリクエストを使用すると、提供されたリンクからブラウザーでファイルを開き、そのコピーをローカル マシンに保存できます。

例:

```text theme={null}
http://localhost/Flexicapture12/Server/FCAuth/Reporting/BatchState/View
http://localhost/Flexicapture12/Server/FCAuth/Reporting/BatchRouting/View
```

<div id="get-business-process-reporting-reports-using-a-powershell-script">
  ## PowerShell スクリプトを使用して Business Process Reporting レポートを取得する
</div>

以下のスクリプトを使用すると、**Administrator** または **Monitoring Operator** ロールを持つテナントユーザーは、ビジネスプロセスのモニタリングデータを取得できます。

レポートは、スクリプトを実行したフォルダーに CSV 形式で保存されます。

```powershell theme={null}
$serviceHost = 'http://localhost' #ホスト
$user=$null #ユーザー
$pass=$null #パスワード
$tenant=$null #テナント名
$baseUrl = $serviceHost
if( $user ) {
    $baseUrl += '/flexicapture12/server/FCAuth/Reporting/'
    } else {    $baseUrl += '/flexicapture12/server/Reporting/'
    }function createBasicCredentials() #パスワードを暗号化された文字列に変換します
{
    $secpasswd = ConvertTo-SecureString $pass -AsPlainText -Force
    return New-Object System.Management.Automation.PSCredential($user, $secpasswd)
}
function getListFromUrl( $url ) #入力された資格情報を使用して認証します
{
    if( $tenant ) {
        $url = $url + '?Tenant=' + [uri]::EscapeUriString( $tenant );
    }
    if( $user ) {
        $creds = createBasicCredentials -user $user -pass $pass
        $response = Invoke-WebRequest -Credential $creds -Uri $url;
    } else {
        $response = Invoke-WebRequest -UseDefaultCredentials -Uri $url;
    }
    $fileList = $response.ToString() | ConvertFrom-Json;
    return $fileList.reportFiles;
}
function getBatchStateFileList() #BatchState ファイルの一覧を要求します
{
    $url = $baseUrl + 'BatchState/List';
    return getListFromUrl -url $url
}
function getBatchRoutingFileList() #BatchRouting ファイルの一覧を要求します
{
    $url = $baseUrl + 'BatchRouting/List';
    return getListFromUrl -url $url
}
function downloadFile ( $fileName, $outDir ) #ファイルをダウンロードします
{
    $url = $baseUrl + 'BatchState/File/' + [uri]::EscapeUriString( $fileName );
    if( $tenant ) {
        $url = $url + '?Tenant=' + [uri]::EscapeUriString( $tenant );
    }
    $outPath = Join-Path -Path $outDir -ChildPath $fileName
    if( $user ) {
        $creds = createBasicCredentials -user $user -pass $pass
        $response = Invoke-WebRequest -Credential $creds -Uri $url;
        $response = Invoke-WebRequest -Credential $creds -Uri $url -OutFile $outPath
    } else {
        $response = Invoke-WebRequest -UseDefaultCredentials -Uri $url -OutFile $outPath
    }
}
$files = getBatchStateFileList; #BatchState ファイルをカレントディレクトリにダウンロードします
foreach ($file in $files) {
    downloadFile -fileName $file -outDir '.\'
}
$files = getBatchRoutingFileList; #BatchRouting ファイルをカレントディレクトリにダウンロードします
foreach ($file in $files) {
    downloadFile -fileName $file -outDir '.\'
}
```
