MergeDocumentsExtended (Application-Level)

You are here:

This method helps to generate a document by merging several documents stored in the file system together. This version contains additional options over the MergeDocuments method.

Authentication

This method requires an authentication token if the access level of the application is set to Restricted.

Request

Target Endpoint

POST /Api/Applications/MergeDocumentsExtended

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.
DocumentMergeInformationInfos Object

 

[

{ “DocumentKey”: “guid”,

“InsertPageBreak”: true

},

{

“DocumentKey”: “guid”,

“InsertPageBreak”: true

}

]

Required

 

List of corresponding (DocumentMergeInfo) objects, corresponding to the receipts from running GenerateDocument with OutputMode = 1 (StoreInFileSystem), including additional options found on the corresponding (DocumentMergeInfo) DTO.

 

This object includes a property that indicates whether or not to insert a page break after the current page.

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 MergeDocumentsExtended 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/MergeDocumentsExtended HTTP/1.1
Authorization: Bearer Do3l_2l3uLdmYX76u-BufLzuuhFPOE-nRZDyU0adiFk1
Content-Type: application/json
Host: dev7.pagos.com

Body (formatted)

{
       "DocumentMergeInformationInfos": [
             {
                    "DocumentKey": "b3fa406a-cd09-46ef-895e-34c2f69afae1",
                    "InsertPageBreak": true
             },
             {
                    "DocumentKey": "4e9c3cee-60ad-41d6-bfd4-bffd58730850",
                    "InsertPageBreak": true
             }
       ],
       "PrintMode": 1,
       "DeleteCachedFiles": true,
       "ApplicationKey": "a4dcfb4f0464453b928ce1d6bcfb6aa3"
}
Request Sample (Unrestricted)

Headers

POST /Api/Applications/MergeDocumentsExtended HTTP/1.1
Content-Type: application/json
Host: dev7.pagos.com

 

Body (formatted)

{
       "DocumentMergeInformationInfos": [
             {
                    "DocumentKey": "b3fa406a-cd09-46ef-895e-34c2f69afae1",
                    "InsertPageBreak": true
             },
             {
                    "DocumentKey": "4e9c3cee-60ad-41d6-bfd4-bffd58730850",
                    "InsertPageBreak": true
             }
       ],
       "PrintMode": 1,
       "DeleteCachedFiles": true,
       "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."
       ]
}