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
(Tcl) 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
load ./chilkat.dll # This example assumes the Chilkat API to have been previously unlocked. # See Global Unlock Sample for sample code. set http [new_CkHttp] # 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. set jsonToken [new_CkJsonObject] # Load a previously obtained OAuth2 access token. set success [CkJsonObject_LoadFile $jsonToken "qa_data/tokens/docusign.json"] if {$success == 0} then { puts [CkJsonObject_lastErrorText $jsonToken] delete_CkHttp $http delete_CkJsonObject $jsonToken exit } CkHttp_put_AuthToken $http [CkJsonObject_stringOf $jsonToken "access_token"] # Use an account ID obtained from DocuSign Get User Account Data set sbResponseBody [new_CkStringBuilder] set success [CkHttp_QuickGetSb $http "https://account-d.docusign.com/restapi/v2/accounts/18b4799a-xxxx-xxxx-xxxx-b5b4b8a97604/brands" $sbResponseBody] if {$success == 0} then { puts [CkHttp_lastErrorText $http] delete_CkHttp $http delete_CkJsonObject $jsonToken delete_CkStringBuilder $sbResponseBody exit } set json [new_CkJsonObject] CkJsonObject_LoadSb $json $sbResponseBody CkJsonObject_put_EmitCompact $json 0 puts "Response Body:" puts [CkJsonObject_emit $json] set respStatusCode [CkHttp_get_LastStatus $http] puts "Response Status Code = $respStatusCode" if {$respStatusCode >= 400} then { puts "Response Header:" puts [CkHttp_lastHeader $http] puts "Failed." delete_CkHttp $http delete_CkJsonObject $jsonToken delete_CkStringBuilder $sbResponseBody delete_CkJsonObject $json exit } # 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 set recipientBrandIdDefault [CkJsonObject_stringOf $json "recipientBrandIdDefault"] set senderBrandIdDefault [CkJsonObject_stringOf $json "senderBrandIdDefault"] set i 0 set count_i [CkJsonObject_SizeOfArray $json "brands"] while {$i < $count_i} { CkJsonObject_put_I $json $i set brandCompany [CkJsonObject_stringOf $json "brands[i].brandCompany"] set brandId [CkJsonObject_stringOf $json "brands[i].brandId"] set brandName [CkJsonObject_stringOf $json "brands[i].brandName"] set errorDetailsErrorCode [CkJsonObject_stringOf $json "brands[i].errorDetails.errorCode"] set errorDetailsMessage [CkJsonObject_stringOf $json "brands[i].errorDetails.message"] set isOverridingCompanyName [CkJsonObject_stringOf $json "brands[i].isOverridingCompanyName"] set isSendingDefault [CkJsonObject_stringOf $json "brands[i].isSendingDefault"] set isSigningDefault [CkJsonObject_stringOf $json "brands[i].isSigningDefault"] set logosPrimary [CkJsonObject_stringOf $json "brands[i].logos.primary"] set logosSecondary [CkJsonObject_stringOf $json "brands[i].logos.secondary"] set logosEmail [CkJsonObject_stringOf $json "brands[i].logos.email"] set resourcesEmail [CkJsonObject_stringOf $json "brands[i].resources.email"] set resourcesSending [CkJsonObject_stringOf $json "brands[i].resources.sending"] set resourcesSigning [CkJsonObject_stringOf $json "brands[i].resources.signing"] set resourcesSigningCaptive [CkJsonObject_stringOf $json "brands[i].resources.signingCaptive"] set j 0 set count_j [CkJsonObject_SizeOfArray $json "brands[i].colors"] while {$j < $count_j} { CkJsonObject_put_J $json $j set j [expr $j + 1] } set j 0 set count_j [CkJsonObject_SizeOfArray $json "brands[i].landingPages"] while {$j < $count_j} { CkJsonObject_put_J $json $j set j [expr $j + 1] } set j 0 set count_j [CkJsonObject_SizeOfArray $json "brands[i].links"] while {$j < $count_j} { CkJsonObject_put_J $json $j set linkType [CkJsonObject_stringOf $json "brands[i].links[j].linkType"] set urlOrMailTo [CkJsonObject_stringOf $json "brands[i].links[j].urlOrMailTo"] set linkText [CkJsonObject_stringOf $json "brands[i].links[j].linkText"] set showLink [CkJsonObject_stringOf $json "brands[i].links[j].showLink"] set j [expr $j + 1] } set j 0 set count_j [CkJsonObject_SizeOfArray $json "brands[i].emailContent"] while {$j < $count_j} { CkJsonObject_put_J $json $j set emailContentType [CkJsonObject_stringOf $json "brands[i].emailContent[j].emailContentType"] set content [CkJsonObject_stringOf $json "brands[i].emailContent[j].content"] set emailToLink [CkJsonObject_stringOf $json "brands[i].emailContent[j].emailToLink"] set linkText [CkJsonObject_stringOf $json "brands[i].emailContent[j].linkText"] set j [expr $j + 1] } set i [expr $i + 1] } delete_CkHttp $http delete_CkJsonObject $jsonToken delete_CkStringBuilder $sbResponseBody delete_CkJsonObject $json |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.