Unicode C
Unicode C
DocuSign List Folder Items
See more DocuSign Examples
Retrieves a list of the envelopes in the specified folder.Chilkat Unicode C Downloads
#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkStringBuilderW.h>
void ChilkatSample(void)
{
BOOL success;
HCkHttpW http;
HCkJsonObjectW jsonToken;
HCkStringBuilderW sbResponseBody;
HCkJsonObjectW jResp;
int respStatusCode;
const wchar_t *ownerName;
const wchar_t *envelopeId;
const wchar_t *envelopeUri;
const wchar_t *status;
const wchar_t *senderName;
const wchar_t *senderEmail;
const wchar_t *createdDateTime;
const wchar_t *sentDateTime;
const wchar_t *completedDateTime;
const wchar_t *subject;
const wchar_t *templateId;
const wchar_t *name;
const wchar_t *shared;
const wchar_t *password;
const wchar_t *description;
const wchar_t *lastModified;
int pageCount;
const wchar_t *uri;
const wchar_t *is21CFRPart11;
const wchar_t *isSignatureProviderEnvelope;
int j;
int count_j;
const wchar_t *fieldId;
const wchar_t *show;
const wchar_t *required;
const wchar_t *value;
const wchar_t *configurationType;
const wchar_t *errorDetailsErrorCode;
const wchar_t *errorDetailsMessage;
const wchar_t *resultSetSize;
const wchar_t *startPosition;
const wchar_t *endPosition;
const wchar_t *totalSetSize;
const wchar_t *previousUri;
const wchar_t *nextUri;
int i;
int count_i;
success = FALSE;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
// Implements the following HTTP request:
// GET /restapi/v2.1/accounts/{accountId}/folders/{folderId}
// Adds the "Authorization: Bearer eyJ0eXAi.....UE8Kl_V8KroQ" header.
jsonToken = CkJsonObjectW_Create();
// Load a previously obtained OAuth2 access token.
success = CkJsonObjectW_LoadFile(jsonToken,L"qa_data/tokens/docusign.json");
if (success == FALSE) {
wprintf(L"%s\n",CkJsonObjectW_lastErrorText(jsonToken));
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(jsonToken);
return;
}
CkHttpW_putAuthToken(http,CkJsonObjectW_stringOf(jsonToken,L"access_token"));
// Use your account ID and a valid folderId here:
CkHttpW_SetUrlVar(http,L"accountId",L"7f3f65ed-5e87-418d-94c1-92499ddc8252");
CkHttpW_SetUrlVar(http,L"folderId",L"94644782-31b7-4f82-a2c1-26d8a9306f8c");
sbResponseBody = CkStringBuilderW_Create();
success = CkHttpW_QuickGetSb(http,L"https://demo.docusign.net/restapi/v2.1/accounts/{$accountId}/folders/{$folderId}",sbResponseBody);
if (success == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(jsonToken);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
jResp = CkJsonObjectW_Create();
CkJsonObjectW_LoadSb(jResp,sbResponseBody);
CkJsonObjectW_putEmitCompact(jResp,FALSE);
wprintf(L"Response Body:\n");
wprintf(L"%s\n",CkJsonObjectW_emit(jResp));
respStatusCode = CkHttpW_getLastStatus(http);
wprintf(L"Response Status Code = %d\n",respStatusCode);
if (respStatusCode >= 400) {
wprintf(L"Response Header:\n");
wprintf(L"%s\n",CkHttpW_lastResponseHeader(http));
wprintf(L"Failed.\n");
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(jsonToken);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
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.
resultSetSize = CkJsonObjectW_stringOf(jResp,L"resultSetSize");
startPosition = CkJsonObjectW_stringOf(jResp,L"startPosition");
endPosition = CkJsonObjectW_stringOf(jResp,L"endPosition");
totalSetSize = CkJsonObjectW_stringOf(jResp,L"totalSetSize");
previousUri = CkJsonObjectW_stringOf(jResp,L"previousUri");
nextUri = CkJsonObjectW_stringOf(jResp,L"nextUri");
i = 0;
count_i = CkJsonObjectW_SizeOfArray(jResp,L"folderItems");
while (i < count_i) {
CkJsonObjectW_putI(jResp,i);
ownerName = CkJsonObjectW_stringOf(jResp,L"folderItems[i].ownerName");
envelopeId = CkJsonObjectW_stringOf(jResp,L"folderItems[i].envelopeId");
envelopeUri = CkJsonObjectW_stringOf(jResp,L"folderItems[i].envelopeUri");
status = CkJsonObjectW_stringOf(jResp,L"folderItems[i].status");
senderName = CkJsonObjectW_stringOf(jResp,L"folderItems[i].senderName");
senderEmail = CkJsonObjectW_stringOf(jResp,L"folderItems[i].senderEmail");
createdDateTime = CkJsonObjectW_stringOf(jResp,L"folderItems[i].createdDateTime");
sentDateTime = CkJsonObjectW_stringOf(jResp,L"folderItems[i].sentDateTime");
completedDateTime = CkJsonObjectW_stringOf(jResp,L"folderItems[i].completedDateTime");
subject = CkJsonObjectW_stringOf(jResp,L"folderItems[i].subject");
templateId = CkJsonObjectW_stringOf(jResp,L"folderItems[i].templateId");
name = CkJsonObjectW_stringOf(jResp,L"folderItems[i].name");
shared = CkJsonObjectW_stringOf(jResp,L"folderItems[i].shared");
password = CkJsonObjectW_stringOf(jResp,L"folderItems[i].password");
description = CkJsonObjectW_stringOf(jResp,L"folderItems[i].description");
lastModified = CkJsonObjectW_stringOf(jResp,L"folderItems[i].lastModified");
pageCount = CkJsonObjectW_IntOf(jResp,L"folderItems[i].pageCount");
uri = CkJsonObjectW_stringOf(jResp,L"folderItems[i].uri");
is21CFRPart11 = CkJsonObjectW_stringOf(jResp,L"folderItems[i].is21CFRPart11");
isSignatureProviderEnvelope = CkJsonObjectW_stringOf(jResp,L"folderItems[i].isSignatureProviderEnvelope");
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"folderItems[i].customFields");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
fieldId = CkJsonObjectW_stringOf(jResp,L"folderItems[i].customFields[j].fieldId");
name = CkJsonObjectW_stringOf(jResp,L"folderItems[i].customFields[j].name");
show = CkJsonObjectW_stringOf(jResp,L"folderItems[i].customFields[j].show");
required = CkJsonObjectW_stringOf(jResp,L"folderItems[i].customFields[j].required");
value = CkJsonObjectW_stringOf(jResp,L"folderItems[i].customFields[j].value");
configurationType = CkJsonObjectW_stringOf(jResp,L"folderItems[i].customFields[j].configurationType");
errorDetailsErrorCode = CkJsonObjectW_stringOf(jResp,L"folderItems[i].customFields[j].errorDetails.errorCode");
errorDetailsMessage = CkJsonObjectW_stringOf(jResp,L"folderItems[i].customFields[j].errorDetails.message");
j = j + 1;
}
i = i + 1;
}
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(jsonToken);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
}