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 Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(PureBasic) Send DocuSign XML Request

Demonstrates how to send a DocuSign XML request.

Important:This example requires Chillkat v9.5.0.75 or greater.

Chilkat PureBasic Module Download

Chilkat PureBasic Module

IncludeFile "CkHttp.pb"
IncludeFile "CkXml.pb"
IncludeFile "CkHttpResponse.pb"
IncludeFile "CkHttpRequest.pb"

Procedure ChilkatExample()

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

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

    CkHttpRequest::setCkHttpVerb(req, "POST")

    ;  Replace "12999999" with your own account number. (12999999 is a ficticious account number)
    CkHttpRequest::setCkPath(req, "/restapi/v2/accounts/12999999/envelopes")

    CkHttpRequest::ckAddHeader(req,"Accept","application/xml")

    ;  Don't worry about the boundary string.  Chilkat will automatically generate one and include it.
    CkHttpRequest::setCkContentType(req, "multipart/form-data")

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

    CkXml::setCkTag(xmlCred, "DocuSignCredentials")
    CkXml::ckUpdateChildContent(xmlCred,"Username","YOUR_DOCUSIGN_USERNAME")
    CkXml::ckUpdateChildContent(xmlCred,"Password","YOUR_DOCUSIGN_PASSWORD")
    CkXml::ckUpdateChildContent(xmlCred,"IntegratorKey","ABCD-12345678-1234-AAAA-BBBB-abcdabcdabcd")
    CkXml::setCkEmitXmlDecl(xmlCred, 0)
    CkXml::setCkEmitCompact(xmlCred, 1)
    CkHttpRequest::ckAddHeader(req,"X-DocuSign-Authentication",CkXml::ckGetXml(xmlCred))

    ;  Don't worry about Host or Content-Length headers, Chilkat automatically adds them...

    ;  Build the XML for the 1st body part..
    xml.i = CkXml::ckCreate()
    If xml.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkXml::setCkTag(xml, "envelopeDefinition")
    CkXml::ckAddAttribute(xml,"xmlns","http://www.docusign.com/restapi")
    CkXml::ckUpdateChildContent(xml,"emailSubject","Signature Request: Test Test:001019:033611")
    CkXml::ckUpdateChildContent(xml,"status","sent")
    CkXml::ckUpdateChildContent(xml,"documents|document|documentId","1")
    CkXml::ckUpdateChildContent(xml,"documents|document|name","001019_TestTest_RetailDeals_163357")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|hostEmail","admin@chilkatsoft.com")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|hostName","Chilkat Admin")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|signerName","Test  Test")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|recipientId","1")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|routingOrder","1")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|signerEmail","test@tyest.com")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere|anchorIgnoreIfNotPresent","True")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere|anchorString","\SDP")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere|optional","False")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[1]|anchorIgnoreIfNotPresent","True")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[1]|anchorString","\OSDP")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[1]|optional","True")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[2]|anchorIgnoreIfNotPresent","True")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[2]|anchorString","\OPSSDP")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[2]|optional","True")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[2]|scaleValue","0.7")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[3]|anchorIgnoreIfNotPresent","True")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[3]|anchorString","\PSSDP")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[3]|optional","False")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[3]|scaleValue","0.7")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere|anchorIgnoreIfNotPresent","True")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere|anchorString","\IDP")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere|optional","False")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[1]|anchorIgnoreIfNotPresent","True")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[1]|anchorString","\OIDP")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[1]|optional","True")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[2]|anchorIgnoreIfNotPresent","True")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[2]|anchorString","\OPSIDP")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[2]|optional","True")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[2]|scaleValue","0.5")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[3]|anchorIgnoreIfNotPresent","True")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[3]|anchorString","\PSIDP")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[3]|optional","False")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[3]|scaleValue","0.5")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|hostEmail","admin@chilkatsoft.com")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|hostName","Chilkat Admin")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|signerName","Dealer Representative")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|recipientId","2")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|routingOrder","2")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere|anchorIgnoreIfNotPresent","True")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere|anchorString","\DSDP")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere|optional","False")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere[1]|anchorIgnoreIfNotPresent","True")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere[1]|anchorString","\DOSDP")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere[1]|optional","True")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere|anchorIgnoreIfNotPresent","True")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere|anchorString","\DIDP")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere|optional","False")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere[1]|anchorIgnoreIfNotPresent","True")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere[1]|anchorString","\DOIDP")
    CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere[1]|optional","True")
    CkXml::setCkEmitXmlDecl(xml, 0)

    Debug CkXml::ckGetXml(xml)

    CkXml::setCkEmitCompact(xml, 1)

    ;  IMPORTANT: This example requires Chilkat v9.5.0.75 or greater.
    CkHttpRequest::ckAddStringForUpload2(req,"","",CkXml::ckGetXml(xml),"utf-8","application/xml")
    CkHttpRequest::ckAddFileForUpload2(req,"","qa_data/pdf/signatureForm.pdf","application/pdf")
    CkHttpRequest::ckAddSubHeader(req,1,"Content-Disposition","file; filename=" + Chr(34) + "signatureForm.pdf" + Chr(34) + ";documentid=1")

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

    CkHttp::setCkSessionLogFilename(http, "qa_output/log.txt")

    resp.i = CkHttp::ckSynchronousRequest(http,"na2.docusign.net",443,1,req)
    If CkHttp::ckLastMethodSuccess(http) <> 1
        Debug CkHttp::ckLastErrorText(http)
        CkHttpRequest::ckDispose(req)
        CkXml::ckDispose(xmlCred)
        CkXml::ckDispose(xml)
        CkHttp::ckDispose(http)
        ProcedureReturn
    EndIf

    If CkHttpResponse::ckStatusCode(resp) <> 201
        Debug CkHttpResponse::ckBodyStr(resp)
        Debug "Response status code: " + Str(CkHttpResponse::ckStatusCode(resp))
        Debug "Failed."
        CkHttpResponse::ckDispose(resp)

        CkHttpRequest::ckDispose(req)
        CkXml::ckDispose(xmlCred)
        CkXml::ckDispose(xml)
        CkHttp::ckDispose(http)
        ProcedureReturn
    EndIf

    ;  Examine the response..
    CkXml::ckLoadXml(xml,CkHttpResponse::ckBodyStr(resp))
    envelopeId.s = CkXml::ckGetChildContent(xml,"envelopeId")
    Debug "envelopeId = " + envelopeId
    status.s = CkXml::ckGetChildContent(xml,"status")
    Debug "status = " + status
    statusDateTime.s = CkXml::ckGetChildContent(xml,"statusDateTime")
    Debug "statusDateTime = " + statusDateTime
    uri.s = CkXml::ckGetChildContent(xml,"uri")
    Debug "uri = " + uri

    CkHttpResponse::ckDispose(resp)



    CkHttpRequest::ckDispose(req)
    CkXml::ckDispose(xmlCred)
    CkXml::ckDispose(xml)
    CkHttp::ckDispose(http)


    ProcedureReturn
EndProcedure

 

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