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

# Get data using the API

> Retrieve Business Process Reporting data from ABBYY FlexiCapture using BatchState and BatchRouting entry points, GET requests, and a PowerShell CSV script.

## Path to the Business Process Reporting data storage

Entry points:

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

The full path to the data storage is a link that can be modified.

Example:

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

For access via the ABBYY FlexiCapture authentication module, `/FCAuth` is added to the link.

Authorized access is allowed in the following cases:

* For authorized ABBYY FlexiCapture users.
* When using SAML/JWT tokens.

Example:

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

If the tenant is not the default one, the `?Tenant=<tenant name>` parameter is added to the link.

Example:

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

## Create requests

Only GET requests are accepted.

* **List** returns a list of filenames in JSON format.
* **File** returns a file with the specified name (which should be encoded in URL format).
* **View** returns a list of filenames in HTML format and inserts links to the files using the **File** command described above. This request allows you to use the provided links to open files in your browser and save copies of them to your local machine.

Examples:

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

## Get Business Process Reporting reports using a PowerShell script

The script below lets tenant users with the **Administrator** or **Monitoring Operator** role get business process monitoring data.

Reports are saved in CSV format to the folder where the script was launched from.

```powershell theme={null}
$serviceHost = 'http://localhost' #Host
$user=$null #User
$pass=$null #Password
$tenant=$null #Tenant name
$baseUrl = $serviceHost
if( $user ) {
    $baseUrl += '/flexicapture12/server/FCAuth/Reporting/'
    } else {    $baseUrl += '/flexicapture12/server/Reporting/'
    }function createBasicCredentials() #Transforms password to encrypted strings
{
    $secpasswd = ConvertTo-SecureString $pass -AsPlainText -Force
    return New-Object System.Management.Automation.PSCredential($user, $secpasswd)
}
function getListFromUrl( $url ) #Authenticates using entered credentials
{
    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() #Requests a list of BatchState files
{
    $url = $baseUrl + 'BatchState/List';
    return getListFromUrl -url $url
}
function getBatchRoutingFileList() #Requests a list of BatchRouting files
{
    $url = $baseUrl + 'BatchRouting/List';
    return getListFromUrl -url $url
}
function downloadFile ( $fileName, $outDir ) #Downloads files
{
    $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; #Uploads BatchState files to the current directory
foreach ($file in $files) {
    downloadFile -fileName $file -outDir '.\'
}
$files = getBatchRoutingFileList; #Uploads BatchRouting files to the current directory
foreach ($file in $files) {
    downloadFile -fileName $file -outDir '.\'
}
```
