DS Server

POST /documentprocessing/document/append

Endpoint

POST https://example.com/documentprocessing/document/append

Description

Combines documents by appending them divided by a new section, paragraph or nothing.

Examples

The following example appends two documents to create one PDF document.

# Request:
curl --location --request POST 'https://trial.dsserver.io/documentprocessing/document/append?returnFormat=PDF' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer GphAd1R0npJM9OuX2y9mUa4cfqPMOg6p' \
    --data-raw '{
        "documents":[
            {
                "document": "UEsDBBQAAAAIAAACAAC5EQAA[..]="
            },
            {
                "document": "JVBERi0xLjQKMSAwIG9iago8[..]",
                "documentDivider": 1
            }
        ]
    }'

# Result:
"JVBERi0xLjQNJeLjz9MNMSAwIG9iago8PAovVH[..]"

Authorization

This endpoint supports the OAuth authorization method. DS Server checks the access token only when OAuth is enabled in the admin portal (see Enable OAuth). With OAuth disabled, the default of a new installation, the endpoint accepts requests without a token.

DS Server implements OAuth as the authorization method. Two flows are supported:

  • Authorization Code
  • Client Credentials

To use the Client Credentials flow, switch on Allow “Client Credentials” grant type in the security profile (see OAuth Grant Types).

In both cases, a valid access token returned from the OAuth endpoints must be passed in a Bearer Authorization Header, as a Query Parameter or in a Cookie.

Authorization Header

Header fieldDescription
AuthorizationA Bearer authorization header (also called token authentication) contains the OAuth access token. The authorization method and a space i.e. "Bearer " is then put before your valid access token. For example: Authorization: Bearer 4796E23054E64BC773CACBCAF24AD179DE9A3

Query Parameter

Query parameterDescription
access_tokenThe access token is passed directly in the endpoint URL as a query string. For example: ?access_token=4796E23054E64BC773CACBCAF24AD179DE9A3

Cookie

CookieDescription
access_tokenThe access token is passed in a cookie named access_token. For example: Cookie: access_token=4796E23054E64BC773CACBCAF24AD179DE9A3

Request Parameters

NameTypeValueOptional
returnFormatStringA string that specifies the format of the created document. Possible values are: "PDF", "PDFA", "RTF", "DOC", "DOCX", "HTML", "TX" and "TXT" (plain text). Default value is "PDF".yes

Request Payload

TypeValue
AppendBodyThe AppendBody object contains the documents encoded as Base64 strings and a DocumentSettings object.

AppendBody

NameTypeValueOptional
documentsAppendDocument[]The documents that are appended including divider options.no
documentSettingsDocumentSettingsDocument settings to specify document properties such as title and author.yes

AppendDocument

NameTypeValueOptional
documentStringThe document as a Base64 encoded string.no
documentDividerIntegerThe document divider option. Possible values: 1 (None), 2 (NewParagraph), 3 (NewSection). Pass the number; a name such as "NewSection" is refused with 400.yes

DocumentSettings

NameTypeValueOptional
authorStringSets the document's author.yes
creationDateDateTime (String)Sets the document's creation date which will be saved in the document.yes
lastModificationDateDateTime (String)Sets the date the document is last modified.yes
creatorApplicationStringSets the application, which has created the document.yes
documentSubjectStringSets the document's subject string which will be saved in the document. PDF limitation: The length is limited to 2000 characters.yes
documentTitleStringSets the document's title that will be saved in the document. PDF limitation: The length is limited to 2000 characters.yes
userPasswordStringSpecifies the password for the user to open the document.yes

Success Response

StatusDescription
200On success, the HTTP status code in the response header is 200 (OK). The response body contains the resulting document encoded as a Base64 encoded string.

Error Response

StatusDescription
401A 401 (Unauthorized) with an empty body is returned, if OAuth is enabled and the request has no valid access token.
400A 400 (Bad Request) is returned, if the body can't be read as an AppendBody object. The body is a problem details object (application/json) with the title "One or more validation errors occurred." and the message per field in errors. This check comes before the license check.
415A 415 (Unsupported Media Type) is returned, if the Content-Type header of a request with a body is not application/json.
405A 405 (Method Not Allowed) with an empty body and the header Allow: POST is returned for any other HTTP method, for example GET.
400A 400 (Bad Request) is returned, if DS Server is not licensed or the license is invalid. On a server that is not registered, the body is the JSON string "DS Server is not registered." (application/json). DS Server checks the license before the parameter values, but after it has read the body and the typed query parameters.
400A 400 (Bad Request) is returned, if no data is found in the AppendBody object.
400A 400 (Bad Request) is returned, if no documents were found in the AppendBody object.
400A 400 (Bad Request) is returned, if the uploaded document is not valid.