Sample code for 30+ languages & platforms
Unicode C++

DocuSign List Folder Items

See more DocuSign Examples

Retrieves a list of the envelopes in the specified folder.

Chilkat Unicode C++ Downloads

Unicode C++
#include <CkHttpW.h>
#include <CkJsonObjectW.h>
#include <CkStringBuilderW.h>

void ChilkatSample(void)
    {
    bool success = false;

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

    CkHttpW http;

    // Implements the following HTTP request:
    // GET /restapi/v2.1/accounts/{accountId}/folders/{folderId}

    // Adds the "Authorization: Bearer eyJ0eXAi.....UE8Kl_V8KroQ" header.
    CkJsonObjectW jsonToken;
    // Load a previously obtained OAuth2 access token.
    success = jsonToken.LoadFile(L"qa_data/tokens/docusign.json");
    if (success == false) {
        wprintf(L"%s\n",jsonToken.lastErrorText());
        return;
    }

    http.put_AuthToken(jsonToken.stringOf(L"access_token"));

    // Use your account ID and a valid folderId here:
    http.SetUrlVar(L"accountId",L"7f3f65ed-5e87-418d-94c1-92499ddc8252");
    http.SetUrlVar(L"folderId",L"94644782-31b7-4f82-a2c1-26d8a9306f8c");

    CkStringBuilderW sbResponseBody;
    success = http.QuickGetSb(L"https://demo.docusign.net/restapi/v2.1/accounts/{$accountId}/folders/{$folderId}",sbResponseBody);
    if (success == false) {
        wprintf(L"%s\n",http.lastErrorText());
        return;
    }

    CkJsonObjectW jResp;
    jResp.LoadSb(sbResponseBody);
    jResp.put_EmitCompact(false);

    wprintf(L"Response Body:\n");
    wprintf(L"%s\n",jResp.emit());

    int respStatusCode = http.get_LastStatus();
    wprintf(L"Response Status Code = %d\n",respStatusCode);
    if (respStatusCode >= 400) {
        wprintf(L"Response Header:\n");
        wprintf(L"%s\n",http.lastResponseHeader());
        wprintf(L"Failed.\n");
        return;
    }

    // Sample JSON response:
    // (Sample code for parsing the JSON response is shown below)

    // {
    //   "resultSetSize": "sample string 1",
    //   "startPosition": "sample string 2",
    //   "endPosition": "sample string 3",
    //   "totalSetSize": "sample string 4",
    //   "previousUri": "sample string 5",
    //   "nextUri": "sample string 6",
    //   "folderItems": [
    //     {
    //       "ownerName": "sample string 1",
    //       "envelopeId": "sample string 2",
    //       "envelopeUri": "sample string 3",
    //       "status": "sample string 4",
    //       "senderName": "sample string 5",
    //       "senderEmail": "sample string 6",
    //       "createdDateTime": "sample string 7",
    //       "sentDateTime": "sample string 8",
    //       "completedDateTime": "sample string 9",
    //       "subject": "sample string 10",
    //       "templateId": "sample string 11",
    //       "name": "sample string 12",
    //       "shared": "sample string 13",
    //       "password": "sample string 14",
    //       "description": "sample string 15",
    //       "lastModified": "sample string 16",
    //       "pageCount": 17,
    //       "uri": "sample string 18",
    //       "is21CFRPart11": "sample string 19",
    //       "isSignatureProviderEnvelope": "sample string 20",
    //       "customFields": [
    //         {
    //           "fieldId": "sample string 1",
    //           "name": "sample string 2",
    //           "show": "sample string 3",
    //           "required": "sample string 4",
    //           "value": "sample string 5",
    //           "configurationType": "sample string 6",
    //           "errorDetails": {
    //             "errorCode": "sample string 1",
    //             "message": "sample string 2"
    //           }
    //         }
    //       ]
    //     }
    //   ]
    // }

    // Sample code for parsing the JSON response...
    // Use the following online tool to generate parsing code from sample JSON:
    // Generate Parsing Code from JSON

    // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
    // See this example explaining how this memory should be used: const char * functions.

    const wchar_t *ownerName = 0;
    const wchar_t *envelopeId = 0;
    const wchar_t *envelopeUri = 0;
    const wchar_t *status = 0;
    const wchar_t *senderName = 0;
    const wchar_t *senderEmail = 0;
    const wchar_t *createdDateTime = 0;
    const wchar_t *sentDateTime = 0;
    const wchar_t *completedDateTime = 0;
    const wchar_t *subject = 0;
    const wchar_t *templateId = 0;
    const wchar_t *name = 0;
    const wchar_t *shared = 0;
    const wchar_t *password = 0;
    const wchar_t *description = 0;
    const wchar_t *lastModified = 0;
    int pageCount;
    const wchar_t *uri = 0;
    const wchar_t *is21CFRPart11 = 0;
    const wchar_t *isSignatureProviderEnvelope = 0;
    int j;
    int count_j;
    const wchar_t *fieldId = 0;
    const wchar_t *show = 0;
    const wchar_t *required = 0;
    const wchar_t *value = 0;
    const wchar_t *configurationType = 0;
    const wchar_t *errorDetailsErrorCode = 0;
    const wchar_t *errorDetailsMessage = 0;

    const wchar_t *resultSetSize = jResp.stringOf(L"resultSetSize");
    const wchar_t *startPosition = jResp.stringOf(L"startPosition");
    const wchar_t *endPosition = jResp.stringOf(L"endPosition");
    const wchar_t *totalSetSize = jResp.stringOf(L"totalSetSize");
    const wchar_t *previousUri = jResp.stringOf(L"previousUri");
    const wchar_t *nextUri = jResp.stringOf(L"nextUri");
    int i = 0;
    int count_i = jResp.SizeOfArray(L"folderItems");
    while (i < count_i) {
        jResp.put_I(i);
        ownerName = jResp.stringOf(L"folderItems[i].ownerName");
        envelopeId = jResp.stringOf(L"folderItems[i].envelopeId");
        envelopeUri = jResp.stringOf(L"folderItems[i].envelopeUri");
        status = jResp.stringOf(L"folderItems[i].status");
        senderName = jResp.stringOf(L"folderItems[i].senderName");
        senderEmail = jResp.stringOf(L"folderItems[i].senderEmail");
        createdDateTime = jResp.stringOf(L"folderItems[i].createdDateTime");
        sentDateTime = jResp.stringOf(L"folderItems[i].sentDateTime");
        completedDateTime = jResp.stringOf(L"folderItems[i].completedDateTime");
        subject = jResp.stringOf(L"folderItems[i].subject");
        templateId = jResp.stringOf(L"folderItems[i].templateId");
        name = jResp.stringOf(L"folderItems[i].name");
        shared = jResp.stringOf(L"folderItems[i].shared");
        password = jResp.stringOf(L"folderItems[i].password");
        description = jResp.stringOf(L"folderItems[i].description");
        lastModified = jResp.stringOf(L"folderItems[i].lastModified");
        pageCount = jResp.IntOf(L"folderItems[i].pageCount");
        uri = jResp.stringOf(L"folderItems[i].uri");
        is21CFRPart11 = jResp.stringOf(L"folderItems[i].is21CFRPart11");
        isSignatureProviderEnvelope = jResp.stringOf(L"folderItems[i].isSignatureProviderEnvelope");
        j = 0;
        count_j = jResp.SizeOfArray(L"folderItems[i].customFields");
        while (j < count_j) {
            jResp.put_J(j);
            fieldId = jResp.stringOf(L"folderItems[i].customFields[j].fieldId");
            name = jResp.stringOf(L"folderItems[i].customFields[j].name");
            show = jResp.stringOf(L"folderItems[i].customFields[j].show");
            required = jResp.stringOf(L"folderItems[i].customFields[j].required");
            value = jResp.stringOf(L"folderItems[i].customFields[j].value");
            configurationType = jResp.stringOf(L"folderItems[i].customFields[j].configurationType");
            errorDetailsErrorCode = jResp.stringOf(L"folderItems[i].customFields[j].errorDetails.errorCode");
            errorDetailsMessage = jResp.stringOf(L"folderItems[i].customFields[j].errorDetails.message");
            j = j + 1;
        }

        i = i + 1;
    }
    }