Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Unicode C) Yousign: Download Information about Previously Uploaded FileDemonstrates how to download the information (in JSON format) about a file previously uploaded. For more information, see https://dev.yousign.com/?version=latest#26513de1-9fab-44d5-96b1-70fe3b3de7a7
#include <C_CkHttpW.h> #include <C_CkStringBuilderW.h> #include <C_CkJsonObjectW.h> void ChilkatSample(void) { HCkHttpW http; BOOL success; HCkStringBuilderW sbResponseBody; HCkJsonObjectW jResp; 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; int i; int count_i; // 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/{{id}}' \ // --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/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",sbResponseBody); if (success == FALSE) { wprintf(L"%s\n",CkHttpW_lastErrorText(http)); CkHttpW_Dispose(http); 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_lastHeader(http)); wprintf(L"Failed.\n"); CkHttpW_Dispose(http); CkStringBuilderW_Dispose(sbResponseBody); CkJsonObjectW_Dispose(jResp); return; } // Sample JSON response: // (Sample code for parsing the JSON response is shown below) // { // "id": "/files/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", // "name": "The best name for my file.pdf", // "type": "signable", // "contentType": "application/pdf", // "description": null, // "createdAt": "2018-12-07T08:10:21+01:00", // "updatedAt": "2018-12-07T08:10:21+01:00", // "sha256": "bb57ae2b2ca6ad0133a699350d1a6f6c8cdfde3cf872cf526585d306e4675cc2", // "metadata": [ // ], // "workspace": "/workspaces/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", // "creator": null, // "protected": false, // "position": 0, // "parent": null // } // 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. id = CkJsonObjectW_stringOf(jResp,L"id"); name = CkJsonObjectW_stringOf(jResp,L"name"); v_type = CkJsonObjectW_stringOf(jResp,L"type"); contentType = CkJsonObjectW_stringOf(jResp,L"contentType"); description = CkJsonObjectW_stringOf(jResp,L"description"); createdAt = CkJsonObjectW_stringOf(jResp,L"createdAt"); updatedAt = CkJsonObjectW_stringOf(jResp,L"updatedAt"); sha256 = CkJsonObjectW_stringOf(jResp,L"sha256"); workspace = CkJsonObjectW_stringOf(jResp,L"workspace"); creator = CkJsonObjectW_stringOf(jResp,L"creator"); v_protected = CkJsonObjectW_BoolOf(jResp,L"protected"); position = CkJsonObjectW_IntOf(jResp,L"position"); parent = CkJsonObjectW_stringOf(jResp,L"parent"); i = 0; count_i = CkJsonObjectW_SizeOfArray(jResp,L"metadata"); while (i < count_i) { CkJsonObjectW_putI(jResp,i); i = i + 1; } CkHttpW_Dispose(http); CkStringBuilderW_Dispose(sbResponseBody); CkJsonObjectW_Dispose(jResp); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.