Chilkat HOME Android™ Classic ASP C C++ C# Mono C# .NET Core C# C# UWP/WinRT DataFlex Delphi ActiveX Delphi DLL Visual FoxPro Java Lianja MFC Objective-C Perl PHP ActiveX PHP Extension PowerBuilder PowerShell PureBasic CkPython Chilkat2-Python Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ Visual Basic 6.0 VB.NET VB.NET UWP/WinRT VBScript Xojo Plugin Node.js Excel Go
(MFC) 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 <CkHttp.h> #include <CkJsonObject.h> #include <CkStringBuilder.h> void ChilkatSample(void) { CkString strOut; // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. CkHttp http; bool success; // 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. CkJsonObject jsonToken; // Load a previously obtained OAuth2 access token. success = jsonToken.LoadFile("qa_data/tokens/docusign.json"); if (success == false) { strOut.append(jsonToken.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } http.put_AuthToken(jsonToken.stringOf("access_token")); // Use an account ID obtained from DocuSign Get User Account Data CkStringBuilder sbResponseBody; success = http.QuickGetSb("https://account-d.docusign.com/restapi/v2/accounts/18b4799a-xxxx-xxxx-xxxx-b5b4b8a97604/brands",sbResponseBody); if (success == false) { strOut.append(http.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } CkJsonObject json; json.LoadSb(sbResponseBody); json.put_EmitCompact(false); strOut.append("Response Body:"); strOut.append("\r\n"); strOut.append(json.emit()); strOut.append("\r\n"); int respStatusCode = http.get_LastStatus(); strOut.append("Response Status Code = "); strOut.appendInt(respStatusCode); strOut.append("\r\n"); if (respStatusCode >= 400) { strOut.append("Response Header:"); strOut.append("\r\n"); strOut.append(http.lastHeader()); strOut.append("\r\n"); strOut.append("Failed."); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); 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. const char *brandCompany = 0; const char *brandId = 0; const char *brandName = 0; const char *errorDetailsErrorCode = 0; const char *errorDetailsMessage = 0; const char *isOverridingCompanyName = 0; const char *isSendingDefault = 0; const char *isSigningDefault = 0; const char *logosPrimary = 0; const char *logosSecondary = 0; const char *logosEmail = 0; const char *resourcesEmail = 0; const char *resourcesSending = 0; const char *resourcesSigning = 0; const char *resourcesSigningCaptive = 0; int j; int count_j; const char *linkType = 0; const char *urlOrMailTo = 0; const char *linkText = 0; const char *showLink = 0; const char *emailContentType = 0; const char *content = 0; const char *emailToLink = 0; const char *recipientBrandIdDefault = json.stringOf("recipientBrandIdDefault"); const char *senderBrandIdDefault = json.stringOf("senderBrandIdDefault"); int i = 0; int count_i = json.SizeOfArray("brands"); while (i < count_i) { json.put_I(i); brandCompany = json.stringOf("brands[i].brandCompany"); brandId = json.stringOf("brands[i].brandId"); brandName = json.stringOf("brands[i].brandName"); errorDetailsErrorCode = json.stringOf("brands[i].errorDetails.errorCode"); errorDetailsMessage = json.stringOf("brands[i].errorDetails.message"); isOverridingCompanyName = json.stringOf("brands[i].isOverridingCompanyName"); isSendingDefault = json.stringOf("brands[i].isSendingDefault"); isSigningDefault = json.stringOf("brands[i].isSigningDefault"); logosPrimary = json.stringOf("brands[i].logos.primary"); logosSecondary = json.stringOf("brands[i].logos.secondary"); logosEmail = json.stringOf("brands[i].logos.email"); resourcesEmail = json.stringOf("brands[i].resources.email"); resourcesSending = json.stringOf("brands[i].resources.sending"); resourcesSigning = json.stringOf("brands[i].resources.signing"); resourcesSigningCaptive = json.stringOf("brands[i].resources.signingCaptive"); j = 0; count_j = json.SizeOfArray("brands[i].colors"); while (j < count_j) { json.put_J(j); j = j + 1; } j = 0; count_j = json.SizeOfArray("brands[i].landingPages"); while (j < count_j) { json.put_J(j); j = j + 1; } j = 0; count_j = json.SizeOfArray("brands[i].links"); while (j < count_j) { json.put_J(j); linkType = json.stringOf("brands[i].links[j].linkType"); urlOrMailTo = json.stringOf("brands[i].links[j].urlOrMailTo"); linkText = json.stringOf("brands[i].links[j].linkText"); showLink = json.stringOf("brands[i].links[j].showLink"); j = j + 1; } j = 0; count_j = json.SizeOfArray("brands[i].emailContent"); while (j < count_j) { json.put_J(j); emailContentType = json.stringOf("brands[i].emailContent[j].emailContentType"); content = json.stringOf("brands[i].emailContent[j].content"); emailToLink = json.stringOf("brands[i].emailContent[j].emailToLink"); linkText = json.stringOf("brands[i].emailContent[j].linkText"); j = j + 1; } i = i + 1; } SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); } |
© 2000-2022 Chilkat Software, Inc. All Rights Reserved.