Chilkat Online Tools

unicodeC / DocuSign eSignature REST API / Deletes envelope custom fields in a template.

Back to Collection Items

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

void ChilkatSample(void)
    {
    HCkHttpW http;
    BOOL success;
    HCkJsonObjectW json;
    HCkStringBuilderW sbRequestBody;
    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.

    // {
    //   "password": "sample string 1",
    //   "textCustomFields": [
    //     {
    //       "fieldId": "sample string 1",
    //       "name": "sample string 2",
    //       "show": "sample string 3",
    //       "required": "sample string 4",
    //       "value": "sample string 5",
    //       "configurationType": "sample string 6"
    //     }
    //   ],
    //   "listCustomFields": [
    //     {
    //       "listItems": [
    //         "sample string 1"
    //       ],
    //       "fieldId": "sample string 1",
    //       "name": "sample string 2",
    //       "show": "sample string 3",
    //       "required": "sample string 4",
    //       "value": "sample string 5",
    //       "configurationType": "sample string 6"
    //     }
    //   ]
    // }

    json = CkJsonObjectW_Create();
    CkJsonObjectW_UpdateString(json,L"password",L"sample string 1");
    CkJsonObjectW_UpdateString(json,L"textCustomFields[0].fieldId",L"sample string 1");
    CkJsonObjectW_UpdateString(json,L"textCustomFields[0].name",L"sample string 2");
    CkJsonObjectW_UpdateString(json,L"textCustomFields[0].show",L"sample string 3");
    CkJsonObjectW_UpdateString(json,L"textCustomFields[0].required",L"sample string 4");
    CkJsonObjectW_UpdateString(json,L"textCustomFields[0].value",L"sample string 5");
    CkJsonObjectW_UpdateString(json,L"textCustomFields[0].configurationType",L"sample string 6");
    CkJsonObjectW_UpdateString(json,L"listCustomFields[0].listItems[0]",L"sample string 1");
    CkJsonObjectW_UpdateString(json,L"listCustomFields[0].fieldId",L"sample string 1");
    CkJsonObjectW_UpdateString(json,L"listCustomFields[0].name",L"sample string 2");
    CkJsonObjectW_UpdateString(json,L"listCustomFields[0].show",L"sample string 3");
    CkJsonObjectW_UpdateString(json,L"listCustomFields[0].required",L"sample string 4");
    CkJsonObjectW_UpdateString(json,L"listCustomFields[0].value",L"sample string 5");
    CkJsonObjectW_UpdateString(json,L"listCustomFields[0].configurationType",L"sample string 6");

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

    sbRequestBody = CkStringBuilderW_Create();
    CkJsonObjectW_EmitSb(json,sbRequestBody);

    resp = CkHttpW_PTextSb(http,L"DELETE",L"https://domain.com/v2.1/accounts/{{accountId}}/templates/{{templateId}}/custom_fields",sbRequestBody,L"utf-8",L"application/json",FALSE,FALSE);
    if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkJsonObjectW_Dispose(json);
        CkStringBuilderW_Dispose(sbRequestBody);
        return;
    }

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


    CkHttpW_Dispose(http);
    CkJsonObjectW_Dispose(json);
    CkStringBuilderW_Dispose(sbRequestBody);

    }

Curl Command

curl -X DELETE
	-H "Accept: application/json"
	-H "Authorization: Bearer {{accessToken}}"
	-d '{
  "password": "sample string 1",
  "textCustomFields": [
    {
      "fieldId": "sample string 1",
      "name": "sample string 2",
      "show": "sample string 3",
      "required": "sample string 4",
      "value": "sample string 5",
      "configurationType": "sample string 6"
    }
  ],
  "listCustomFields": [
    {
      "listItems": [
        "sample string 1"
      ],
      "fieldId": "sample string 1",
      "name": "sample string 2",
      "show": "sample string 3",
      "required": "sample string 4",
      "value": "sample string 5",
      "configurationType": "sample string 6"
    }
  ]
}'
https://domain.com/v2.1/accounts/{{accountId}}/templates/{{templateId}}/custom_fields

Postman Collection Item JSON

{
  "name": "Deletes envelope custom fields in a template.",
  "request": {
    "method": "DELETE",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      },
      {
        "key": "Authorization",
        "value": "Bearer {{accessToken}}"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n  \"password\": \"sample string 1\",\n  \"textCustomFields\": [\n    {\n      \"fieldId\": \"sample string 1\",\n      \"name\": \"sample string 2\",\n      \"show\": \"sample string 3\",\n      \"required\": \"sample string 4\",\n      \"value\": \"sample string 5\",\n      \"configurationType\": \"sample string 6\"\n    }\n  ],\n  \"listCustomFields\": [\n    {\n      \"listItems\": [\n        \"sample string 1\"\n      ],\n      \"fieldId\": \"sample string 1\",\n      \"name\": \"sample string 2\",\n      \"show\": \"sample string 3\",\n      \"required\": \"sample string 4\",\n      \"value\": \"sample string 5\",\n      \"configurationType\": \"sample string 6\"\n    }\n  ]\n}"
    },
    "url": {
      "raw": "{{baseUrl}}/v2.1/accounts/{{accountId}}/templates/{{templateId}}/custom_fields",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "v2.1",
        "accounts",
        "{{accountId}}",
        "templates",
        "{{templateId}}",
        "custom_fields"
      ],
      "variable": [
        {
          "key": "accountId",
          "value": "{{accountId}}",
          "type": "string"
        },
        {
          "key": "templateId",
          "value": "{{templateId}}",
          "type": "string"
        }
      ]
    },
    "description": "Deletes envelope custom fields in a template."
  },
  "response": [
  ]
}