Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

PureBasic Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Google Vision
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
JCC Cyprus
Jira
Lightspeed
MYOB
Magento
Mailgun
Malaysia MyInvois

Mastercard
MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
Salesforce
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
TikTok Shop
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(PureBasic) DocuSign Download Envelope Document (PDF)

See more DocuSign Examples

Retrieves the specified document from the envelope. The response body of this method is the PDF file as a byte stream. You can get the file name and document ID from the response's Content-Disposition header.

For more information, see https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/envelopedocuments/get/

Chilkat PureBasic Module Download

Chilkat PureBasic Module

IncludeFile "CkBinData.pb"
IncludeFile "CkHttp.pb"
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkJsonObject.pb"
IncludeFile "CkMime.pb"

Procedure ChilkatExample()

    ; This example assumes the Chilkat API to have been previously unlocked.
    ; See Global Unlock Sample for sample code.

    http.i = CkHttp::ckCreate()
    If http.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    success.i

    ; Implements the following HTTP request:
    ; GET /restapi/v2.1/accounts/{accountId}/envelopes/{envelopeId}/documents/1

    ; Adds the "Authorization: Bearer eyJ0eXAi.....UE8Kl_V8KroQ" header.
    jsonToken.i = CkJsonObject::ckCreate()
    If jsonToken.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    ; Load a previously obtained OAuth2 access token.
    success = CkJsonObject::ckLoadFile(jsonToken,"qa_data/tokens/docusign.json")
    If success = 0
        Debug CkJsonObject::ckLastErrorText(jsonToken)
        CkHttp::ckDispose(http)
        CkJsonObject::ckDispose(jsonToken)
        ProcedureReturn
    EndIf

    CkHttp::setCkAuthToken(http, CkJsonObject::ckStringOf(jsonToken,"access_token"))

    ; Use your account ID and a valid envelopeId here:
    CkHttp::ckSetUrlVar(http,"accountId","7f3f65ed-5e87-418d-94c1-92499ddc8252")
    CkHttp::ckSetUrlVar(http,"envelopeId","90d7e40a-b4bd-4ccd-bf38-c80e37954a13")

    url.s = "https://demo.docusign.net/restapi/v2.1/accounts/{$accountId}/envelopes/{$envelopeId}/documents/1"
    bd.i = CkBinData::ckCreate()
    If bd.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    success = CkHttp::ckDownloadBd(http,url,bd)
    If success = 0
        Debug CkHttp::ckLastErrorText(http)
        CkHttp::ckDispose(http)
        CkJsonObject::ckDispose(jsonToken)
        CkBinData::ckDispose(bd)
        ProcedureReturn
    EndIf

    respStatusCode.i = CkHttp::ckLastStatus(http)
    Debug "Response Status Code = " + Str(respStatusCode)
    If respStatusCode <> 200
        Debug "Response Header:"
        Debug CkHttp::ckLastResponseHeader(http)
        ; The response body contains an error message.
        Debug CkBinData::ckGetString(bd,"utf-8")
        Debug "Failed."
        CkHttp::ckDispose(http)
        CkJsonObject::ckDispose(jsonToken)
        CkBinData::ckDispose(bd)
        ProcedureReturn
    EndIf

    ; The response indicated success.
    ; Get the filename from the Content-Disposition header and save to a file.
    mime.i = CkMime::ckCreate()
    If mime.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkMime::ckLoadMime(mime,CkHttp::ckLastResponseHeader(http))

    filename.s = CkMime::ckGetHeaderFieldAttribute(mime,"Content-Disposition","filename")
    Debug "filename = " + filename

    sbPath.i = CkStringBuilder::ckCreate()
    If sbPath.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkStringBuilder::ckAppend(sbPath,"C:/aaworkarea/")
    CkStringBuilder::ckAppend(sbPath,filename)
    success = CkBinData::ckWriteFile(bd,CkStringBuilder::ckGetAsString(sbPath))
    If success = 0
        Debug "Failed to save to output file."
    Else
        Debug "Wrote " + CkStringBuilder::ckGetAsString(sbPath)
    EndIf



    CkHttp::ckDispose(http)
    CkJsonObject::ckDispose(jsonToken)
    CkBinData::ckDispose(bd)
    CkMime::ckDispose(mime)
    CkStringBuilder::ckDispose(sbPath)


    ProcedureReturn
EndProcedure

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.