Please enable JavaScript to view this site.

The manual for the JobRouter developer

If you want to upload additional files in a document, use the POST route /application/jobarchive/archives/:archive/documents/:revisionId/clippedfiles. With the archive parameter you determine the archive (archive GUID or archive table). The document is identified by the revision ID (parameter revisionId). The files are transferred in the array files in the HTTP request body.

If the clipping was successful a new revision of the documents is created. Their ID is returned in the response:

{

    "archivedocumentrevisions": [

        {

            "revisionId": 1235

        }

    ]

}

Please note: Only users with archive profiles can store documents in the archive and clip files.

Example: Clip files on an already archived document

guzzlehttp

// User has been authenticated already

 

// Define files

$files = [

  [

    'name' => 'files[0]',

    'contents' => fopen('/path/to/my/rest/file.pdf', 'r'),

  ],

  [

    'name' => 'files[1]',

    'contents' => fopen('/path/to/my/rest/note.txt', 'r'),

  ],

];

 

try {

 

    $response = $client->request(

        'POST',

        'application/jobarchive/archives/MYTESTARCHIVE/documents/1234/clippedfiles',

        [

            'multipart' => $files,

        ]

    );

 

    if ($response->getStatusCode() == 200) {

        $body = json_decode($response->getBody(), true);

        echo "Document ID: ";

        echo $body['archivedocumentrevisions'][0]['revisionId'] . "\n";

    }

 

} catch (Exception $e) {

    echo "Error during performance: " . $e->getMessage() . "\n";

}

 

// Finish user session

cURL

// User has been authenticated already

 

// Define files

$file1 = new CURLFile('/path/to/invoice/file1.pdf');

$file2 = new CURLFile('/path/to/invoice/file2.pdf');

 

$files = [

    'files[0]' => $file1,

    'files[1]' => $file2

];

 

curl_setopt($curlHandle, CURLOPT_URL,

    'http://example.org/jobrouter/api/rest/v2/application/' .

    'jobarchive/archives/invoices/documents/1234/clippedfiles');

curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);

curl_setopt($curlHandle, CURLOPT_POST, 1);

curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $files);

curl_setopt($curlHandle, CURLOPT_COOKIEFILE, 'path/to/cookie/file.cookie');

 

$response = curl_exec($curlHandle);

$statusCode = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE);

 

curl_close();

 

if ($statusCode == 200) {

    $documentData = json_decode($response, true);

    echo "Document ID: ";

    echo $documentData['archivedocumentrevisions'][0]['revisionId'] . "\n";

} else {

    echo "Error during performance: Code - " . $statusCode . ", ";

    echo "Response: " . var_export($response, true);

}

 

// Finish user session