MergeDocuments (Application-Level)
This method helps to generate a document by merging several documents stored in the file system together.
Authentication
This method requires an authentication token if the access level of the application is set to Restricted.
Request
Target Endpoint
POST /Api/Applications/MergeDocuments
Parameters
Property Name |
Type |
Is Required? |
Description |
---|---|---|---|
ApplicationKey | String | Required | The application key, corresponding to your specific web service application. This constitutes the identifier for the requested resource. |
CacheKeys | Array of Guid | Required | List of cache keys corresponding to the receipts from running GenerateDocument with
OutputMode = 1 (StoreInFileSystem). |
PrintMode | int | Required | Enum value for what format the output should be returned as:
[0: PDF]: Document will be returned as PDF document. [1: Word]: Document will be returned as a Word (.DOCX document). |
DeleteCachedFiles | bool | Required | Boolean value to specify whether to delete all of the files corresponding to the CacheKeys from the file system after the generation process has completed.
NOTE: These will only be deleted if the merge process output has completed successfully. |
Request Sample (Restricted)
The sample below is a simple request to the MergeDocuments method for a restricted application, clearly designated by the bearer token in the authorization header. The token was retrieved using an authentication request. The process of retrieving an access token is documented here.
Headers
POST /Api/Applications/MergeDocuments HTTP/1.1 Authorization: Bearer Do3l_2l3uLdmYX76u-BufLzuuhFPOE-nRZDyU0adiFk1 Content-Type: application/json Host: dev7.pagos.com
Body (formatted)
{ "CacheKeys": [ "a81aecea-d38c-4973-96bc-964cfa10e9fe", "6f415226-27f6-4c4a-b494-515c6c5d1a64" ], "PrintMode": 1, "DeleteCachedFiles": false, "ApplicationKey": "a4dcfb4f0464453b928ce1d6bcfb6aa3" }
Request Sample (Unrestricted)
Headers
POST /Api/Applications/MergeDocuments HTTP/1.1 Content-Type: application/json Host: dev7.pagos.com
Body (formatted)
{ "CacheKeys": [ "a81aecea-d38c-4973-96bc-964cfa10e9fe", "6f415226-27f6-4c4a-b494-515c6c5d1a64" ], "PrintMode": 1, "DeleteCachedFiles": false, "ApplicationKey": "a4dcfb4f0464453b928ce1d6bcfb6aa3" }
Response
Property Name |
Type |
Description |
---|---|---|
Success | Boolean | Indicated whether or not the request was successful based on the provided token and application key. |
Document | byte[] | Merged document |
CacheKey | string | Null |
InvalidToken | Boolean | If the request is unsuccessful, indicates whether or not the failure was due to token. |
Messages | Array of String | A list of messages, which can be used or captured for diagnostics. When requests are unsuccessful, the reason for the failure will be documented in the Messages list. |
Response Sample (Success)
Headers
HTTP/1.1 200 OK Cache-Control: no-cache, no-store Content-Type: application/json; charset=utf-8
Body (formatted)
{ "Document": " JVBERi0xLjQNCiW0tba3DQoxIDAgb2JqDQo8PA0KL1BhZ2VzIDIgMCBSDQovUGFnZUxheW91dCAvT25lQ29sdW1uDQovVHlwZSAvQ2F0YWxvZw0KL091dHB1dEludGVudHMgWzw8DQovT3V0cHV0Q29uZGl0aW9uICgpDQovT3V0cHV0Q29uZGl0aW9uSWRlbnRpZmllciAoQ3VzdG9tKQ0KL1JlZ2lzdHJ5TmFtZSAoKQ0KL0luZm8gKHNSR0IgSUVDNjEY5ODc2IDAwMDAwIG4NCjAwMDAwNzAxOTUgMDAwMDAgbg0KMDAwMDA3MDUyMCAwMDAwMCBuDQowMDAwMDkwMTc0IDAwMDAwIG4NCnRyYWlsZXINCjw8DQovSW5mbyA2IDAgUg0KL1Jvb3QgMSAwIFINCi9TaXplIDI4DQo+Pg0KDQpzdGFydHhyZWYNCjEwMzQ0Mg0KJSVFT0YNCg==", "CacheKey": "00000000-0000-0000-0000-000000000000", "Success": true, "InvalidToken": false, "Messages": [] }
Response Sample (Failure)
Headers
HTTP/1.1 200 OK Cache-Control: no-cache, no-store Content-Type: application/json; charset=utf-8
Body (formatted)
Example 1:
{ "Document": null, "CacheKey": "00000000-0000-0000-0000-000000000000", "Success": false, "InvalidToken": false, "Messages": [ "The requested resource is restricted and your request did not provide a valid token." ] }
Example 2:
{ "Document": null, "CacheKey": "00000000-0000-0000-0000-000000000000", "Success": false, "InvalidToken": false, "Messages": [ "The following cache keys did not correspond to an existing document: 'a81aecea-d38c-4973-96bc-964cfa10e9fe', '6f415226-27f6-4c4a-b494-515c6c5d1a64', .", "There were no keys that corresponded to existing files in the cache. Please make sure that you generated the corresponding documents before performing server-side merge." ] }