C++
C++
Yousign: List Files
See more Yousign Examples
List Yousign files.Chilkat C++ Downloads
#include <CkHttp.h>
#include <CkStringBuilder.h>
#include <CkJsonObject.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.
CkHttp http;
// 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.
http.put_AuthToken("YOUR_API_KEY");
http.SetRequestHeader("Content-Type","application/json");
CkStringBuilder sbResponseBody;
success = http.QuickGetSb("https://staging-api.yousign.com/files",sbResponseBody);
if (success == false) {
std::cout << http.lastErrorText() << "\r\n";
return;
}
CkJsonObject json;
json.LoadSb(sbResponseBody);
json.put_EmitCompact(false);
std::cout << "Response Body:" << "\r\n";
std::cout << json.emit() << "\r\n";
int respStatusCode = http.get_LastStatus();
std::cout << "Response Status Code = " << respStatusCode << "\r\n";
if (respStatusCode >= 400) {
std::cout << "Response Header:" << "\r\n";
std::cout << http.lastHeader() << "\r\n";
std::cout << "Failed." << "\r\n";
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.
const char *id = json.stringOf("id");
const char *name = json.stringOf("name");
const char *v_type = json.stringOf("type");
const char *contentType = json.stringOf("contentType");
const char *description = json.stringOf("description");
const char *createdAt = json.stringOf("createdAt");
const char *updatedAt = json.stringOf("updatedAt");
const char *sha256 = json.stringOf("sha256");
const char *workspace = json.stringOf("workspace");
const char *creator = json.stringOf("creator");
bool v_protected = json.BoolOf("protected");
int position = json.IntOf("position");
const char *parent = json.stringOf("parent");
bool fieldsCompatible = json.BoolOf("fieldsCompatible");
const char *company = json.stringOf("company");
int i = 0;
int count_i = json.SizeOfArray("metadata");
while (i < count_i) {
json.put_I(i);
i = i + 1;
}
i = 0;
count_i = json.SizeOfArray("fileObjects");
while (i < count_i) {
json.put_I(i);
i = i + 1;
}
}