For retrieving files from archived documents the following GET routes are available:
•/application/jobarchive/archives/:archive/documents/:revisionId/file – Call main file (the file, that is displayed first, when the document is opened in JobRouter)
•/application/jobarchive/archives/:archive/documents/:revisionId/files – Call all document files
•/application/jobarchive/archives/:archive/documents/:revisionId/clippedfiles – Call only the clipped files without the main file
With the archive parameter you determine the archive (Archiv-GUID or archive table). The document is identified by the revision ID (parameter revisionId).
The files are returned with the mime type application/octet-stream (binary data).
Example: Download all files of an archived document
guzzlehttp
// User has been authenticated already
try {
// Request files. If successful, they will be stored in the
// path given in the parameter sink.
$client->request(
'GET',
'application/jobarchive/archives/invoices/documents/123/files',
[
'sink' => '/path/for/downloaded/files/my_files.zip',
]
);
} catch (Exception $e) {
echo "Error during performance: " . $e->getMessage() . "\n";
}
cURL
// User has been authenticated already
curl_setopt($curlHandle, CURLOPT_URL,
'http://example.org/jobrouter/api/rest/v2/application/jobarchive/' .
'archives/invoices/documents/123/files');
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curlHandle, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($curlHandle, CURLOPT_COOKIEFILE, 'path/to/cooke/file.cookie');
$tempFile = fopen('/path/for/downloaded/files/my_files.zip', 'w+');
curl_setopt($curlHandle, CURLOPT_FILE , $tempFile);
$response = curl_exec($curlHandle);
fclose($tempFile);
$statusCode = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE);
if ($statusCode !== 200) {
echo "Error during performance: Code - " . $statusCode . ", ";
echo Response: " . var_export($response, true);
}