Chilkat Online Tools

unicodeC / DocuSign eSignature REST API / 14. Created Embedded View

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.

    // {
    //   "returnUrl": "http://httpbin.org/get",
    //   "authenticationMethod": "none",
    //   "email": "{{email}}",
    //   "userName": "{{userName}}"
    // }

    json = CkJsonObjectW_Create();
    CkJsonObjectW_UpdateString(json,L"returnUrl",L"http://httpbin.org/get");
    CkJsonObjectW_UpdateString(json,L"authenticationMethod",L"none");
    CkJsonObjectW_UpdateString(json,L"email",L"{{email}}");
    CkJsonObjectW_UpdateString(json,L"userName",L"{{userName}}");

    // Adds the "Authorization: Bearer <access_token>" header.
    CkHttpW_putAuthToken(http,L"<access_token>");

    resp = CkHttpW_PostJson3(http,L"https://domain.com/{{apiVersion}}/accounts/{{accountId}}/envelopes/{{envelopeId_draft}}/views/recipient_preview",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 <access_token>"
	-d '{
    "returnUrl": "http://httpbin.org/get",
    "authenticationMethod": "none",
    "email": {{user1}},
    "userName": {{user1_name}}
}'
https://domain.com/{{apiVersion}}/accounts/{{accountId}}/envelopes/{{envelopeId_draft}}/views/recipient_preview

Postman Collection Item JSON

{
  "name": "14. Created Embedded View",
  "request": {
    "auth": {
      "type": "bearer",
      "bearer": [
        {
          "key": "token",
          "value": "{{accessToken}}",
          "type": "string"
        }
      ]
    },
    "method": "POST",
    "header": [
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"returnUrl\": \"http://httpbin.org/get\",\n    \"authenticationMethod\": \"none\",\n    \"email\": {{user1}},\n    \"userName\": {{user1_name}}\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{baseUrl}}/{{apiVersion}}/accounts/{{accountId}}/envelopes/{{envelopeId_draft}}/views/recipient_preview",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "{{apiVersion}}",
        "accounts",
        "{{accountId}}",
        "envelopes",
        "{{envelopeId_draft}}",
        "views",
        "recipient_preview"
      ]
    },
    "description": "In this example, we will create an embedded preview of what our recipients see when the envelope is sent out to them."
  },
  "response": [
  ]
}