GetDocumentStubs (Application-Level)

You are here:

This method allows retrieving available stubs in a document. A stub has to be in double curly braces ( {{StubName}} format). A text stub can be defined in the document text, and an image stub can be defined by adding alt text description to the format of an image. If the document does not contain this notation, method will return an empty list.

Authentication

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

Request

Target Endpoint

POST /Api/Applications/GetDocumentStubs

 

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.
DocumentKey String Required Key generated in the Control Panel UI for the specific document.
IsCaseSensitive Boolean Optional This flag will determine whether to consider case sensitivity when identifying stubs.

When set to True, if there are multiple stubs that are identical except for character case, each will be returned (e.g. “HelloWorld” and “HELLOWORLD”). When set to False, this same scenario will return only the first stub that matches the target pattern (e.g. “HelloWorld”).

The default behavior is True.

Request Sample (Restricted)

The sample below is a simple request to the GetDocumentStubs 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/GetDocumentStubs HTTP/1.1
Authorization: Bearer Do3l_2l3uLdmYX76u-BufLzuuhFPOE-nRZDyU0adiFk1
Content-Type: application/json
Host: dev7.pagos.com

Body (formatted)

{
       "DocumentKey": "3a98a194-6768-432d-a7b7-b33104a5dd76",
       "ApplicationKey": "a4dcfb4f0464453b928ce1d6bcfb6aa3"
}

 

Request Sample (Unrestricted)

Headers

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

 

Body (formatted)

{
       "DocumentKey": "3a98a194-6768-432d-a7b7-b33104a5dd76",
       "ApplicationKey": "a4dcfb4f0464453b928ce1d6bcfb6aa3"
}
Response

Property Name

Type

Description

Success Boolean Indicates whether or not the request was successful based on the provided token and application key.
DocumentStubList Array of Object

[

{ “StubName”: String,

“DocumentStubType”: int,

“Height”: int (only for image stubs),

“Width”: int (only for image stubs),

}

]

List of the document stubs in the document

DocumentStubType: Enum value representing the stub type found:

[0: Text]: Represents a text stub

[1: Image]: Represents an image stub

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)

Example 1:

{
       "DocumentStubList": [
             {
                    "StubName": "DummyTextStub",
          "DocumentStubType": 0,
    },
             {
                    "StubName": "DummyImageStub",
          "DocumentStubType": 1,
                    "Height": 720",
          "Width": 1280,          
             }
       ],
       "Success": true,
       "InvalidToken": false,
       "Messages": []
}

Example 2:

{
       "DocumentStubList": [],
       "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:

{
       "DocumentStubList": null,
       "Success": false,
       "InvalidToken": true,
       "Messages": [
             "The requested resource is restricted and your request did not provide a valid token."
       ]
}

Example 2:

{
       "DocumentStubList": null,
       "Success": false,
       "InvalidToken": false,
       "Messages": [
             "The submitted document key does not correspond to any existing document in the system. Please check the Control Panel for the appropriate document key."
       ]
}