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
(AutoIt) 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
; This example assumes the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. $oHttp = ObjCreate("Chilkat.Http") Local $bSuccess ; 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. $oJsonToken = ObjCreate("Chilkat.JsonObject") ; Load a previously obtained OAuth2 access token. $bSuccess = $oJsonToken.LoadFile("qa_data/tokens/docusign.json") If ($bSuccess = False) Then ConsoleWrite($oJsonToken.LastErrorText & @CRLF) Exit EndIf $oHttp.AuthToken = $oJsonToken.StringOf("access_token") ; Use an account ID obtained from DocuSign Get User Account Data $oSbResponseBody = ObjCreate("Chilkat.StringBuilder") $bSuccess = $oHttp.QuickGetSb("https://account-d.docusign.com/restapi/v2/accounts/18b4799a-xxxx-xxxx-xxxx-b5b4b8a97604/brands",$oSbResponseBody) If ($bSuccess = False) Then ConsoleWrite($oHttp.LastErrorText & @CRLF) Exit EndIf $oJson = ObjCreate("Chilkat.JsonObject") $oJson.LoadSb($oSbResponseBody) $oJson.EmitCompact = False ConsoleWrite("Response Body:" & @CRLF) ConsoleWrite($oJson.Emit() & @CRLF) Local $iRespStatusCode = $oHttp.LastStatus ConsoleWrite("Response Status Code = " & $iRespStatusCode & @CRLF) If ($iRespStatusCode >= 400) Then ConsoleWrite("Response Header:" & @CRLF) ConsoleWrite($oHttp.LastHeader & @CRLF) ConsoleWrite("Failed." & @CRLF) Exit EndIf ; 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 Local $sBrandCompany Local $sBrandId Local $sBrandName Local $sErrorDetailsErrorCode Local $sErrorDetailsMessage Local $sIsOverridingCompanyName Local $sIsSendingDefault Local $sIsSigningDefault Local $sLogosPrimary Local $sLogosSecondary Local $sLogosEmail Local $sResourcesEmail Local $sResourcesSending Local $sResourcesSigning Local $sResourcesSigningCaptive Local $iJ Local $iCount_j Local $sLinkType Local $sUrlOrMailTo Local $sLinkText Local $showLink Local $sEmailContentType Local $sContent Local $sEmailToLink Local $sRecipientBrandIdDefault = $oJson.StringOf("recipientBrandIdDefault") Local $senderBrandIdDefault = $oJson.StringOf("senderBrandIdDefault") Local $i = 0 Local $iCount_i = $oJson.SizeOfArray("brands") While $i < $iCount_i $oJson.I = $i $sBrandCompany = $oJson.StringOf("brands[i].brandCompany") $sBrandId = $oJson.StringOf("brands[i].brandId") $sBrandName = $oJson.StringOf("brands[i].brandName") $sErrorDetailsErrorCode = $oJson.StringOf("brands[i].errorDetails.errorCode") $sErrorDetailsMessage = $oJson.StringOf("brands[i].errorDetails.message") $sIsOverridingCompanyName = $oJson.StringOf("brands[i].isOverridingCompanyName") $sIsSendingDefault = $oJson.StringOf("brands[i].isSendingDefault") $sIsSigningDefault = $oJson.StringOf("brands[i].isSigningDefault") $sLogosPrimary = $oJson.StringOf("brands[i].logos.primary") $sLogosSecondary = $oJson.StringOf("brands[i].logos.secondary") $sLogosEmail = $oJson.StringOf("brands[i].logos.email") $sResourcesEmail = $oJson.StringOf("brands[i].resources.email") $sResourcesSending = $oJson.StringOf("brands[i].resources.sending") $sResourcesSigning = $oJson.StringOf("brands[i].resources.signing") $sResourcesSigningCaptive = $oJson.StringOf("brands[i].resources.signingCaptive") $iJ = 0 $iCount_j = $oJson.SizeOfArray("brands[i].colors") While $iJ < $iCount_j $oJson.J = $iJ $iJ = $iJ + 1 Wend $iJ = 0 $iCount_j = $oJson.SizeOfArray("brands[i].landingPages") While $iJ < $iCount_j $oJson.J = $iJ $iJ = $iJ + 1 Wend $iJ = 0 $iCount_j = $oJson.SizeOfArray("brands[i].links") While $iJ < $iCount_j $oJson.J = $iJ $sLinkType = $oJson.StringOf("brands[i].links[j].linkType") $sUrlOrMailTo = $oJson.StringOf("brands[i].links[j].urlOrMailTo") $sLinkText = $oJson.StringOf("brands[i].links[j].linkText") $showLink = $oJson.StringOf("brands[i].links[j].showLink") $iJ = $iJ + 1 Wend $iJ = 0 $iCount_j = $oJson.SizeOfArray("brands[i].emailContent") While $iJ < $iCount_j $oJson.J = $iJ $sEmailContentType = $oJson.StringOf("brands[i].emailContent[j].emailContentType") $sContent = $oJson.StringOf("brands[i].emailContent[j].content") $sEmailToLink = $oJson.StringOf("brands[i].emailContent[j].emailToLink") $sLinkText = $oJson.StringOf("brands[i].emailContent[j].linkText") $iJ = $iJ + 1 Wend $i = $i + 1 Wend |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.