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

# Web APIでレポートをダウンロードする

> Web APIのGetCsv GETリクエストを使用して、ABBYY FlexiCaptureのオペレーターワークロード、処理パフォーマンス、ライセンス消費に関するレポートをCSV形式でダウンロードします。

Web APIを使用して、オペレーターのワークロード、処理済みのドキュメント、特定のクライアントからのドキュメント、その他の条件に関するレポートをダウンロードできます。APIメソッドのパラメーターと出力されるCSVファイルは、管理および監視コンソールでレポートを作成したときに生成されるものと同一です。詳しくは、[レポート](/ja/flexi-capture/web-stations/monitoring-console/reports)を参照してください。

レポートをダウンロードするには、次のURIを使用してGET リクエストを送信します:

```http theme={null}
GET http://localhost/FlexiCapture12/Monitoring/Report/GetCsv?reportType=<reportType>&filterParametersJson=<filterParametersJson>
```

<div id="request-parameters">
  ## リクエストパラメーター
</div>

クエリ文字列に `reportType` と `filterParametersJson` を指定します。

<div id="report-types">
  ### レポートの種類
</div>

`reportType` には、次の値を指定できます。

| Value | Report             |
| ----- | ------------------ |
| `1`   | オペレーター概要レポート       |
| `3`   | 処理パフォーマンスレポート      |
| `9`   | サイトパフォーマンスレポート     |
| `10`  | テナント別ライセンス消費レポート   |
| `11`  | プロジェクト別ライセンス消費レポート |

<div id="report-parameters">
  ### レポートのパラメーター
</div>

`filterParametersJson` は、レポートの生成に使用するパラメーターを受け取ります。パラメーターのセットは、レポートの種類によって異なります。詳細については、各レポートの種類のパラメーターを参照してください。

* [オペレーター概要レポートのパラメーター](/ja/flexi-capture/api/reports/api-reports-operator)
* [処理パフォーマンスレポートのパラメーター](/ja/flexi-capture/api/reports/api-reports-processing)
* [サイトパフォーマンスレポートのパラメーター](/ja/flexi-capture/api/reports/api-reports-performance)
* [テナント別ライセンス消費レポートのパラメーター](/ja/flexi-capture/api/reports/api-reports-consumptionbytenants)
* [プロジェクト別ライセンス消費レポートのパラメーター](/ja/flexi-capture/api/reports/api-reports-consumptionbyprojects)

<div id="example-script">
  ## スクリプトの例
</div>

次のPowerShellスクリプトでは、このAPIを使用してレポートをダウンロードする方法を示します。

```powershell theme={null}
# 認証パラメーター
$endpoint = "https://preprod01.flexicapture.com"
$tenant = "tenantName"
$user = "FCUserName"
$pass = "password"
$filePath = "c:\temp\report.csv"
# レポートパラメーター
$reportType = 3
$jsonparameters = @"
[
    {
        "Name": "dateFrom",
        "Value": "2022-08-31T21:00:00.000Z"
    },
    {
        "Name": "dateTo",
        "Value": "2022-09-01T21:00:00.000Z"
    },
    {
        "Name": "projects",
        "Value": [
            5,
            6,
            7,
            9,
            10,
            11,
            12,
            13,
            14,
            15,
            16,
            17,
            19,
            20,
            28,
            81,
            221
        ]
    },
    {
        "Name": "aggregateByBatchTypes",
        "Value": true
    },
    {
        "Name": "groupByType",
        "Value": 1
    },
    {
        "Name": "grouping",
        "Value": "ProcessingStageName"
    },
    {
        "Name": "columns",
        "Value": [
            "ProjectId",
            "BatchTypeName",
            "ProcessedBatchs",
            "ProcessedDocs"
        ]
    }
]
"@
###################################################
clear
$ErrorActionPreference="stop"
#FlexiCapture SOAP API から認証用の authTicket を取得する
$tenantSuffix=""
$tenantInUrl = ""
if (($tenant -ne $null) -or ($tenant -eq "")) {
    $tenantSuffix= "?Tenant="+$tenant
    $tenantInUrl = "/$tenant"
}
$URL = $endpoint+'/FlexiCapture12/Server/FCAuth/API/Soap'+$tenantSuffix
$SOAPRequest = @"
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soap:Body>
    <FindUser xmlns="urn:http://www.abbyy.com/FlexiCapture">
      <userLogin>$user</userLogin>
    </FindUser>
  </soap:Body>
</soap:Envelope>
"@
$pair = "$($user):$($pass)"
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
$basicAuthValue = "Basic $encodedCreds"
$Headers = @{
    'SOAPAction' = '"#FindUser"'
    'Content-Type' = 'text/xml; charset=utf-8'
    'Authorization' = "$basicAuthValue"
}
$response = Invoke-WebRequest -Uri $URL `
    -Headers $Headers `
    -Body $SOAPRequest `
    -Method 'POST'
$authTicket = $response.Headers['AuthTicket']
#認証 Cookie を作成する
$session = [Microsoft.PowerShell.Commands.WebRequestSession]::new()
$cookie = [System.Net.Cookie]::new('FlexiCaptureTmpPrn', "Ticket=$authTicket")
$session.Cookies.Add($endpoint, $cookie)
# API 経由でレポートを取得して保存する
$uriGet = $endpoint+ "/FlexiCapture12/Monitoring$tenantInUrl/Report/GetCSV?reportType=$reportType&filterParametersJson="
$uriGet += [uri]::EscapeDataString($jsonparameters)
$header = @{
    "Accept" = "*/*"
    "Accept-Encoding" = "gzip, deflate, br"
}
$response = Invoke-RestMethod -Uri $uriGet -Method 'GET' -Headers $header -WebSession $session -OutFile $filePath
```
