Chilkat Online Tools

SQL Server / DocuSign eSignature REST API / Get Responsive HTML Preview for all documents in a template.

Back to Collection Items

-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    -- Important: Do not use nvarchar(max).  See the warning about using nvarchar(max).
    DECLARE @sTmp0 nvarchar(4000)
    -- This example assumes the Chilkat API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    DECLARE @http int
    -- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    -- Use this online tool to generate code from sample JSON: Generate Code to Create JSON

    -- The following JSON is sent in the request body.

    -- {
    --   "documentId": "sample string 1",
    --   "documentGuid": "sample string 2",
    --   "source": "sample string 3",
    --   "displayAnchors": [
    --     {
    --       "startAnchor": "sample string 1",
    --       "endAnchor": "sample string 2",
    --       "removeStartAnchor": true,
    --       "removeEndAnchor": true,
    --       "caseSensitive": true,
    --       "displaySettings": {
    --         "displayLabel": "sample string 1",
    --         "display": "sample string 2",
    --         "displayPageNumber": 3,
    --         "displayOrder": 4,
    --         "tableStyle": "sample string 5",
    --         "cellStyle": "sample string 6",
    --         "inlineOuterStyle": "sample string 7",
    --         "hideLabelWhenOpened": true,
    --         "scrollToTopWhenOpened": true,
    --         "preLabel": "sample string 10",
    --         "labelWhenOpened": "sample string 11",
    --         "collapsibleSettings": {
    --           "containerStyle": "sample string 1",
    --           "outerLabelAndArrowStyle": "sample string 2",
    --           "labelStyle": "sample string 3",
    --           "arrowStyle": "sample string 4",
    --           "arrowClosed": "sample string 5",
    --           "arrowOpen": "sample string 6",
    --           "arrowLocation": "sample string 7",
    --           "arrowColor": "sample string 8",
    --           "arrowSize": "sample string 9",
    --           "onlyArrowIsClickable": true
    --         }
    --       }
    --     }
    --   ],
    --   "removeEmptyTags": "sample string 4",
    --   "headerLabel": "sample string 5",
    --   "displayAnchorPrefix": "sample string 6",
    --   "maxScreenWidth": "sample string 7",
    --   "displayPageNumber": "sample string 8",
    --   "displayOrder": "sample string 9",
    --   "showMobileOptimizedToggle": "sample string 10"
    -- }

    DECLARE @json int
    -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT

    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'documentId', 'sample string 1'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'documentGuid', 'sample string 2'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'source', 'sample string 3'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'displayAnchors[0].startAnchor', 'sample string 1'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'displayAnchors[0].endAnchor', 'sample string 2'
    EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'displayAnchors[0].removeStartAnchor', 1
    EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'displayAnchors[0].removeEndAnchor', 1
    EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'displayAnchors[0].caseSensitive', 1
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'displayAnchors[0].displaySettings.displayLabel', 'sample string 1'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'displayAnchors[0].displaySettings.display', 'sample string 2'
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'displayAnchors[0].displaySettings.displayPageNumber', 3
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'displayAnchors[0].displaySettings.displayOrder', 4
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'displayAnchors[0].displaySettings.tableStyle', 'sample string 5'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'displayAnchors[0].displaySettings.cellStyle', 'sample string 6'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'displayAnchors[0].displaySettings.inlineOuterStyle', 'sample string 7'
    EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'displayAnchors[0].displaySettings.hideLabelWhenOpened', 1
    EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'displayAnchors[0].displaySettings.scrollToTopWhenOpened', 1
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'displayAnchors[0].displaySettings.preLabel', 'sample string 10'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'displayAnchors[0].displaySettings.labelWhenOpened', 'sample string 11'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'displayAnchors[0].displaySettings.collapsibleSettings.containerStyle', 'sample string 1'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'displayAnchors[0].displaySettings.collapsibleSettings.outerLabelAndArrowStyle', 'sample string 2'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'displayAnchors[0].displaySettings.collapsibleSettings.labelStyle', 'sample string 3'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'displayAnchors[0].displaySettings.collapsibleSettings.arrowStyle', 'sample string 4'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'displayAnchors[0].displaySettings.collapsibleSettings.arrowClosed', 'sample string 5'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'displayAnchors[0].displaySettings.collapsibleSettings.arrowOpen', 'sample string 6'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'displayAnchors[0].displaySettings.collapsibleSettings.arrowLocation', 'sample string 7'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'displayAnchors[0].displaySettings.collapsibleSettings.arrowColor', 'sample string 8'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'displayAnchors[0].displaySettings.collapsibleSettings.arrowSize', 'sample string 9'
    EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'displayAnchors[0].displaySettings.collapsibleSettings.onlyArrowIsClickable', 1
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'removeEmptyTags', 'sample string 4'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'headerLabel', 'sample string 5'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'displayAnchorPrefix', 'sample string 6'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'maxScreenWidth', 'sample string 7'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'displayPageNumber', 'sample string 8'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'displayOrder', 'sample string 9'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'showMobileOptimizedToggle', 'sample string 10'

    -- Adds the "Authorization: Bearer {{accessToken}}" header.
    EXEC sp_OASetProperty @http, 'AuthToken', '{{accessToken}}'
    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Accept', 'application/json'

    DECLARE @resp int
    EXEC sp_OAMethod @http, 'PostJson3', @resp OUT, 'https://domain.com/v2.1/accounts/{{accountId}}/templates/{{templateId}}/responsive_html_preview', 'application/json', @json
    EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
    IF @iTmp0 = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @json
        RETURN
      END

    EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
    PRINT @iTmp0
    EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
    PRINT @sTmp0
    EXEC @hr = sp_OADestroy @resp


    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @json


END
GO

Curl Command

curl -X POST
	-H "Accept: application/json"
	-H "Authorization: Bearer {{accessToken}}"
	-d '{
  "documentId": "sample string 1",
  "documentGuid": "sample string 2",
  "source": "sample string 3",
  "displayAnchors": [
    {
      "startAnchor": "sample string 1",
      "endAnchor": "sample string 2",
      "removeStartAnchor": true,
      "removeEndAnchor": true,
      "caseSensitive": true,
      "displaySettings": {
        "displayLabel": "sample string 1",
        "display": "sample string 2",
        "displayPageNumber": 3,
        "displayOrder": 4,
        "tableStyle": "sample string 5",
        "cellStyle": "sample string 6",
        "inlineOuterStyle": "sample string 7",
        "hideLabelWhenOpened": true,
        "scrollToTopWhenOpened": true,
        "preLabel": "sample string 10",
        "labelWhenOpened": "sample string 11",
        "collapsibleSettings": {
          "containerStyle": "sample string 1",
          "outerLabelAndArrowStyle": "sample string 2",
          "labelStyle": "sample string 3",
          "arrowStyle": "sample string 4",
          "arrowClosed": "sample string 5",
          "arrowOpen": "sample string 6",
          "arrowLocation": "sample string 7",
          "arrowColor": "sample string 8",
          "arrowSize": "sample string 9",
          "onlyArrowIsClickable": true
        }
      }
    }
  ],
  "removeEmptyTags": "sample string 4",
  "headerLabel": "sample string 5",
  "displayAnchorPrefix": "sample string 6",
  "maxScreenWidth": "sample string 7",
  "displayPageNumber": "sample string 8",
  "displayOrder": "sample string 9",
  "showMobileOptimizedToggle": "sample string 10"
}'
https://domain.com/v2.1/accounts/{{accountId}}/templates/{{templateId}}/responsive_html_preview

Postman Collection Item JSON

{
  "name": "Get Responsive HTML Preview for all documents in a template.",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      },
      {
        "key": "Authorization",
        "value": "Bearer {{accessToken}}"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n  \"documentId\": \"sample string 1\",\n  \"documentGuid\": \"sample string 2\",\n  \"source\": \"sample string 3\",\n  \"displayAnchors\": [\n    {\n      \"startAnchor\": \"sample string 1\",\n      \"endAnchor\": \"sample string 2\",\n      \"removeStartAnchor\": true,\n      \"removeEndAnchor\": true,\n      \"caseSensitive\": true,\n      \"displaySettings\": {\n        \"displayLabel\": \"sample string 1\",\n        \"display\": \"sample string 2\",\n        \"displayPageNumber\": 3,\n        \"displayOrder\": 4,\n        \"tableStyle\": \"sample string 5\",\n        \"cellStyle\": \"sample string 6\",\n        \"inlineOuterStyle\": \"sample string 7\",\n        \"hideLabelWhenOpened\": true,\n        \"scrollToTopWhenOpened\": true,\n        \"preLabel\": \"sample string 10\",\n        \"labelWhenOpened\": \"sample string 11\",\n        \"collapsibleSettings\": {\n          \"containerStyle\": \"sample string 1\",\n          \"outerLabelAndArrowStyle\": \"sample string 2\",\n          \"labelStyle\": \"sample string 3\",\n          \"arrowStyle\": \"sample string 4\",\n          \"arrowClosed\": \"sample string 5\",\n          \"arrowOpen\": \"sample string 6\",\n          \"arrowLocation\": \"sample string 7\",\n          \"arrowColor\": \"sample string 8\",\n          \"arrowSize\": \"sample string 9\",\n          \"onlyArrowIsClickable\": true\n        }\n      }\n    }\n  ],\n  \"removeEmptyTags\": \"sample string 4\",\n  \"headerLabel\": \"sample string 5\",\n  \"displayAnchorPrefix\": \"sample string 6\",\n  \"maxScreenWidth\": \"sample string 7\",\n  \"displayPageNumber\": \"sample string 8\",\n  \"displayOrder\": \"sample string 9\",\n  \"showMobileOptimizedToggle\": \"sample string 10\"\n}"
    },
    "url": {
      "raw": "{{baseUrl}}/v2.1/accounts/{{accountId}}/templates/{{templateId}}/responsive_html_preview",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "v2.1",
        "accounts",
        "{{accountId}}",
        "templates",
        "{{templateId}}",
        "responsive_html_preview"
      ],
      "variable": [
        {
          "key": "accountId",
          "value": "{{accountId}}",
          "type": "string"
        },
        {
          "key": "templateId",
          "value": "{{templateId}}",
          "type": "string"
        }
      ]
    }
  },
  "response": [
  ]
}