Chilkat Online Tools

Swift3 / DocuSign eSignature REST API / Post Responsive HTML Preview for a document in a template.

Back to Collection Items

func chilkatTest() {
    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    let http = CkoHttp()!
    var success: Bool

    // 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"
    // }

    let json = CkoJsonObject()!
    json.update("documentId", value: "sample string 1")
    json.update("documentGuid", value: "sample string 2")
    json.update("source", value: "sample string 3")
    json.update("displayAnchors[0].startAnchor", value: "sample string 1")
    json.update("displayAnchors[0].endAnchor", value: "sample string 2")
    json.updateBool("displayAnchors[0].removeStartAnchor", value: true)
    json.updateBool("displayAnchors[0].removeEndAnchor", value: true)
    json.updateBool("displayAnchors[0].caseSensitive", value: true)
    json.update("displayAnchors[0].displaySettings.displayLabel", value: "sample string 1")
    json.update("displayAnchors[0].displaySettings.display", value: "sample string 2")
    json.updateInt("displayAnchors[0].displaySettings.displayPageNumber", value: 3)
    json.updateInt("displayAnchors[0].displaySettings.displayOrder", value: 4)
    json.update("displayAnchors[0].displaySettings.tableStyle", value: "sample string 5")
    json.update("displayAnchors[0].displaySettings.cellStyle", value: "sample string 6")
    json.update("displayAnchors[0].displaySettings.inlineOuterStyle", value: "sample string 7")
    json.updateBool("displayAnchors[0].displaySettings.hideLabelWhenOpened", value: true)
    json.updateBool("displayAnchors[0].displaySettings.scrollToTopWhenOpened", value: true)
    json.update("displayAnchors[0].displaySettings.preLabel", value: "sample string 10")
    json.update("displayAnchors[0].displaySettings.labelWhenOpened", value: "sample string 11")
    json.update("displayAnchors[0].displaySettings.collapsibleSettings.containerStyle", value: "sample string 1")
    json.update("displayAnchors[0].displaySettings.collapsibleSettings.outerLabelAndArrowStyle", value: "sample string 2")
    json.update("displayAnchors[0].displaySettings.collapsibleSettings.labelStyle", value: "sample string 3")
    json.update("displayAnchors[0].displaySettings.collapsibleSettings.arrowStyle", value: "sample string 4")
    json.update("displayAnchors[0].displaySettings.collapsibleSettings.arrowClosed", value: "sample string 5")
    json.update("displayAnchors[0].displaySettings.collapsibleSettings.arrowOpen", value: "sample string 6")
    json.update("displayAnchors[0].displaySettings.collapsibleSettings.arrowLocation", value: "sample string 7")
    json.update("displayAnchors[0].displaySettings.collapsibleSettings.arrowColor", value: "sample string 8")
    json.update("displayAnchors[0].displaySettings.collapsibleSettings.arrowSize", value: "sample string 9")
    json.updateBool("displayAnchors[0].displaySettings.collapsibleSettings.onlyArrowIsClickable", value: true)
    json.update("removeEmptyTags", value: "sample string 4")
    json.update("headerLabel", value: "sample string 5")
    json.update("displayAnchorPrefix", value: "sample string 6")
    json.update("maxScreenWidth", value: "sample string 7")
    json.update("displayPageNumber", value: "sample string 8")
    json.update("displayOrder", value: "sample string 9")
    json.update("showMobileOptimizedToggle", value: "sample string 10")

    // Adds the "Authorization: Bearer {{accessToken}}" header.
    http.authToken = "{{accessToken}}"
    http.setRequestHeader("Accept", value: "application/json")

    var resp: CkoHttpResponse? = http.postJson3("https://domain.com/v2.1/accounts/{{accountId}}/templates/{{templateId}}/documents/{{documentId}}/responsive_html_preview", contentType: "application/json", json: json)
    if http.lastMethodSuccess == false {
        print("\(http.lastErrorText!)")
        return
    }

    print("\(resp!.statusCode.intValue)")
    print("\(resp!.bodyStr!)")
    resp = nil

}

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}}/documents/{{documentId}}/responsive_html_preview

Postman Collection Item JSON

{
  "name": "Post Responsive HTML Preview for a document 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}}/documents/{{documentId}}/responsive_html_preview",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "v2.1",
        "accounts",
        "{{accountId}}",
        "templates",
        "{{templateId}}",
        "documents",
        "{{documentId}}",
        "responsive_html_preview"
      ],
      "variable": [
        {
          "key": "accountId",
          "value": "{{accountId}}",
          "type": "string"
        },
        {
          "key": "documentId",
          "value": "{{documentId}}",
          "type": "string"
        },
        {
          "key": "templateId",
          "value": "{{templateId}}",
          "type": "string"
        }
      ]
    }
  },
  "response": [
  ]
}