Chilkat Online Tools

unicodeC / DocuSign Click API / 5. Add Tab to Envelope

Back to Collection Items

#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkHttpResponseW.h>

void ChilkatSample(void)
    {
    HCkHttpW http;
    BOOL success;
    HCkJsonObjectW json;
    HCkHttpResponseW resp;

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

    http = CkHttpW_Create();

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

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

    // {
    //   "signHereTabs": [
    //     {
    //       "anchorString": "test",
    //       "anchorXOffset": "1",
    //       "anchorYOffset": "0",
    //       "anchorIgnoreIfNotPresent": "false",
    //       "anchorUnits": "inches"
    //     }
    //   ]
    // }

    json = CkJsonObjectW_Create();
    CkJsonObjectW_UpdateString(json,L"signHereTabs[0].anchorString",L"test");
    CkJsonObjectW_UpdateString(json,L"signHereTabs[0].anchorXOffset",L"1");
    CkJsonObjectW_UpdateString(json,L"signHereTabs[0].anchorYOffset",L"0");
    CkJsonObjectW_UpdateString(json,L"signHereTabs[0].anchorIgnoreIfNotPresent",L"false");
    CkJsonObjectW_UpdateString(json,L"signHereTabs[0].anchorUnits",L"inches");

    // Adds the "Authorization: Bearer {{accessToken}}" header.
    CkHttpW_putAuthToken(http,L"{{accessToken}}");

    resp = CkHttpW_PostJson3(http,L"https://domain.com/{{apiVersion}}/accounts/{{accountId}}/envelopes/{{envelopeId}}/recipients/{{recipientId}}/tabs",L"application/json",json);
    if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkJsonObjectW_Dispose(json);
        return;
    }

    wprintf(L"%d\n",CkHttpResponseW_getStatusCode(resp));
    wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
    CkHttpResponseW_Dispose(resp);


    CkHttpW_Dispose(http);
    CkJsonObjectW_Dispose(json);

    }

Curl Command

curl -X POST
	-H "Authorization: Bearer {{accessToken}}"
	-d '{
    "signHereTabs": [{
        "anchorString": "test",
        "anchorXOffset": "1",
        "anchorYOffset": "0",
        "anchorIgnoreIfNotPresent": "false",
        "anchorUnits": "inches"
    }]
}'
https://domain.com/{{apiVersion}}/accounts/{{accountId}}/envelopes/{{envelopeId}}/recipients/{{recipientId}}/tabs

Postman Collection Item JSON

{
  "name": "5. Add Tab to Envelope",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Authorization",
        "value": "Bearer {{accessToken}}"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"signHereTabs\": [{\n        \"anchorString\": \"test\",\n        \"anchorXOffset\": \"1\",\n        \"anchorYOffset\": \"0\",\n        \"anchorIgnoreIfNotPresent\": \"false\",\n        \"anchorUnits\": \"inches\"\n    }]\n}"
    },
    "url": {
      "raw": "{{baseUrl}}/{{apiVersion}}/accounts/{{accountId}}/envelopes/{{envelopeId}}/recipients/{{recipientId}}/tabs",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "{{apiVersion}}",
        "accounts",
        "{{accountId}}",
        "envelopes",
        "{{envelopeId}}",
        "recipients",
        "{{recipientId}}",
        "tabs"
      ]
    },
    "description": "In this example, we will modify an evelope and add a tab to a document. This endpoint allows one to modify envelopes after they were created, which is very useful."
  },
  "response": [
  ]
}