Unicode C
Unicode C
Yousign: List Files
See more Yousign Examples
List Yousign files.Chilkat Unicode C Downloads
#include <C_CkHttpW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkJsonObjectW.h>
void ChilkatSample(void)
{
BOOL success;
HCkHttpW http;
HCkStringBuilderW sbResponseBody;
HCkJsonObjectW json;
int respStatusCode;
const wchar_t *id;
const wchar_t *name;
const wchar_t *v_type;
const wchar_t *contentType;
const wchar_t *description;
const wchar_t *createdAt;
const wchar_t *updatedAt;
const wchar_t *sha256;
const wchar_t *workspace;
const wchar_t *creator;
BOOL v_protected;
int position;
const wchar_t *parent;
BOOL fieldsCompatible;
const wchar_t *company;
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 CURL command:
// curl --location --request GET 'https://staging-api.yousign.com/files' \
// --header 'Authorization: Bearer YOUR_API_KEY' \
// --header 'Content-Type: application/json'
// Use the following online tool to generate HTTP code from a CURL command
// Convert a cURL Command to HTTP Source Code
// Adds the "Authorization: Bearer YOUR_API_KEY" header.
CkHttpW_putAuthToken(http,L"YOUR_API_KEY");
CkHttpW_SetRequestHeader(http,L"Content-Type",L"application/json");
sbResponseBody = CkStringBuilderW_Create();
success = CkHttpW_QuickGetSb(http,L"https://staging-api.yousign.com/files",sbResponseBody);
if (success == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
json = CkJsonObjectW_Create();
CkJsonObjectW_LoadSb(json,sbResponseBody);
CkJsonObjectW_putEmitCompact(json,FALSE);
wprintf(L"Response Body:\n");
wprintf(L"%s\n",CkJsonObjectW_emit(json));
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_lastHeader(http));
wprintf(L"Failed.\n");
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(json);
return;
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "id": "\/files\/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
// "name": "abc.pdf",
// "type": "signable",
// "contentType": "application\/pdf",
// "description": null,
// "createdAt": "2020-05-27T09:14:12+02:00",
// "updatedAt": "2020-05-27T09:14:12+02:00",
// "sha256": "ea2a92b0eff5bebfa3ccd869fd61e27bb7fe973d0dff63f106d8b0d614469fa0",
// "metadata": [
// ],
// "workspace": "\/workspaces\/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
// "creator": null,
// "fileObjects": [
// ],
// "protected": false,
// "position": 0,
// "parent": null,
// "fieldsCompatible": true,
// "company": "\/companies\/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
// }
// 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.
id = CkJsonObjectW_stringOf(json,L"id");
name = CkJsonObjectW_stringOf(json,L"name");
v_type = CkJsonObjectW_stringOf(json,L"type");
contentType = CkJsonObjectW_stringOf(json,L"contentType");
description = CkJsonObjectW_stringOf(json,L"description");
createdAt = CkJsonObjectW_stringOf(json,L"createdAt");
updatedAt = CkJsonObjectW_stringOf(json,L"updatedAt");
sha256 = CkJsonObjectW_stringOf(json,L"sha256");
workspace = CkJsonObjectW_stringOf(json,L"workspace");
creator = CkJsonObjectW_stringOf(json,L"creator");
v_protected = CkJsonObjectW_BoolOf(json,L"protected");
position = CkJsonObjectW_IntOf(json,L"position");
parent = CkJsonObjectW_stringOf(json,L"parent");
fieldsCompatible = CkJsonObjectW_BoolOf(json,L"fieldsCompatible");
company = CkJsonObjectW_stringOf(json,L"company");
i = 0;
count_i = CkJsonObjectW_SizeOfArray(json,L"metadata");
while (i < count_i) {
CkJsonObjectW_putI(json,i);
i = i + 1;
}
i = 0;
count_i = CkJsonObjectW_SizeOfArray(json,L"fileObjects");
while (i < count_i) {
CkJsonObjectW_putI(json,i);
i = i + 1;
}
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(json);
}