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) Docusign: Return Brand Data Associated with a UserDemonstrates a call using an OAuth2 access token in combination with the account ID for which we have authorization. For more information, see https://developers.docusign.com/esign-rest-api/guides/authentication/oauth2-jsonwebtoken
#include <C_CkHttpW.h> #include <C_CkJsonObjectW.h> #include <C_CkStringBuilderW.h> void ChilkatSample(void) { HCkHttpW http; BOOL success; HCkJsonObjectW jsonToken; HCkStringBuilderW sbResponseBody; HCkJsonObjectW json; int respStatusCode; const wchar_t *brandCompany; const wchar_t *brandId; const wchar_t *brandName; const wchar_t *errorDetailsErrorCode; const wchar_t *errorDetailsMessage; const wchar_t *isOverridingCompanyName; const wchar_t *isSendingDefault; const wchar_t *isSigningDefault; const wchar_t *logosPrimary; const wchar_t *logosSecondary; const wchar_t *logosEmail; const wchar_t *resourcesEmail; const wchar_t *resourcesSending; const wchar_t *resourcesSigning; const wchar_t *resourcesSigningCaptive; int j; int count_j; const wchar_t *linkType; const wchar_t *urlOrMailTo; const wchar_t *linkText; const wchar_t *showLink; const wchar_t *emailContentType; const wchar_t *content; const wchar_t *emailToLink; const wchar_t *recipientBrandIdDefault; const wchar_t *senderBrandIdDefault; 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 --request GET https://account-d.docusign.com/restapi/v2/accounts/18b4799a-xxxx-xxxx-xxxx-b5b4b8a97604/brands --header "Authorization: Bearer eyJ0eXAi.....UE8Kl_V8KroQ" // 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 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 an account ID obtained from DocuSign Get User Account Data sbResponseBody = CkStringBuilderW_Create(); success = CkHttpW_QuickGetSb(http,L"https://account-d.docusign.com/restapi/v2/accounts/18b4799a-xxxx-xxxx-xxxx-b5b4b8a97604/brands",sbResponseBody); if (success == FALSE) { wprintf(L"%s\n",CkHttpW_lastErrorText(http)); CkHttpW_Dispose(http); CkJsonObjectW_Dispose(jsonToken); 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); CkJsonObjectW_Dispose(jsonToken); CkStringBuilderW_Dispose(sbResponseBody); CkJsonObjectW_Dispose(json); return; } // Sample JSON response: // (Sample code for parsing the JSON response is shown below) // { // "recipientBrandIdDefault": "sample string 1", // "senderBrandIdDefault": "sample string 2", // "brands": [ // { // "brandCompany": "sample string 1", // "brandId": "sample string 2", // "brandName": "sample string 3", // "colors": [ // {} // ], // "errorDetails": { // "errorCode": "sample string 1", // "message": "sample string 2" // }, // "isOverridingCompanyName": "sample string 4", // "isSendingDefault": "sample string 5", // "isSigningDefault": "sample string 6", // "landingPages": [ // {} // ], // "links": [ // { // "linkType": "sample string 1", // "urlOrMailTo": "sample string 2", // "linkText": "sample string 3", // "showLink": "sample string 4" // } // ], // "emailContent": [ // { // "emailContentType": "sample string 1", // "content": "sample string 2", // "emailToLink": "sample string 3", // "linkText": "sample string 4" // } // ], // "logos": { // "primary": "sample string 1", // "secondary": "sample string 2", // "email": "sample string 3" // }, // "resources": { // "email": "sample string 1", // "sending": "sample string 2", // "signing": "sample string 3", // "signingCaptive": "sample string 4" // } // } // ] // } // 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. recipientBrandIdDefault = CkJsonObjectW_stringOf(json,L"recipientBrandIdDefault"); senderBrandIdDefault = CkJsonObjectW_stringOf(json,L"senderBrandIdDefault"); i = 0; count_i = CkJsonObjectW_SizeOfArray(json,L"brands"); while (i < count_i) { CkJsonObjectW_putI(json,i); brandCompany = CkJsonObjectW_stringOf(json,L"brands[i].brandCompany"); brandId = CkJsonObjectW_stringOf(json,L"brands[i].brandId"); brandName = CkJsonObjectW_stringOf(json,L"brands[i].brandName"); errorDetailsErrorCode = CkJsonObjectW_stringOf(json,L"brands[i].errorDetails.errorCode"); errorDetailsMessage = CkJsonObjectW_stringOf(json,L"brands[i].errorDetails.message"); isOverridingCompanyName = CkJsonObjectW_stringOf(json,L"brands[i].isOverridingCompanyName"); isSendingDefault = CkJsonObjectW_stringOf(json,L"brands[i].isSendingDefault"); isSigningDefault = CkJsonObjectW_stringOf(json,L"brands[i].isSigningDefault"); logosPrimary = CkJsonObjectW_stringOf(json,L"brands[i].logos.primary"); logosSecondary = CkJsonObjectW_stringOf(json,L"brands[i].logos.secondary"); logosEmail = CkJsonObjectW_stringOf(json,L"brands[i].logos.email"); resourcesEmail = CkJsonObjectW_stringOf(json,L"brands[i].resources.email"); resourcesSending = CkJsonObjectW_stringOf(json,L"brands[i].resources.sending"); resourcesSigning = CkJsonObjectW_stringOf(json,L"brands[i].resources.signing"); resourcesSigningCaptive = CkJsonObjectW_stringOf(json,L"brands[i].resources.signingCaptive"); j = 0; count_j = CkJsonObjectW_SizeOfArray(json,L"brands[i].colors"); while (j < count_j) { CkJsonObjectW_putJ(json,j); j = j + 1; } j = 0; count_j = CkJsonObjectW_SizeOfArray(json,L"brands[i].landingPages"); while (j < count_j) { CkJsonObjectW_putJ(json,j); j = j + 1; } j = 0; count_j = CkJsonObjectW_SizeOfArray(json,L"brands[i].links"); while (j < count_j) { CkJsonObjectW_putJ(json,j); linkType = CkJsonObjectW_stringOf(json,L"brands[i].links[j].linkType"); urlOrMailTo = CkJsonObjectW_stringOf(json,L"brands[i].links[j].urlOrMailTo"); linkText = CkJsonObjectW_stringOf(json,L"brands[i].links[j].linkText"); showLink = CkJsonObjectW_stringOf(json,L"brands[i].links[j].showLink"); j = j + 1; } j = 0; count_j = CkJsonObjectW_SizeOfArray(json,L"brands[i].emailContent"); while (j < count_j) { CkJsonObjectW_putJ(json,j); emailContentType = CkJsonObjectW_stringOf(json,L"brands[i].emailContent[j].emailContentType"); content = CkJsonObjectW_stringOf(json,L"brands[i].emailContent[j].content"); emailToLink = CkJsonObjectW_stringOf(json,L"brands[i].emailContent[j].emailToLink"); linkText = CkJsonObjectW_stringOf(json,L"brands[i].emailContent[j].linkText"); j = j + 1; } i = i + 1; } CkHttpW_Dispose(http); CkJsonObjectW_Dispose(jsonToken); CkStringBuilderW_Dispose(sbResponseBody); CkJsonObjectW_Dispose(json); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.