Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

Unicode C Examples

Web API Categories

ASN.1
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
Geolocation
Google APIs
Google Calendar
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
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
REST
REST Misc
RSA
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Socket/SSL/TLS
Spider
Stream
Tar Archive
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(Unicode C) Send DocuSign XML Request

Demonstrates how to send a DocuSign XML request.

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

Chilkat C/C++ Library Downloads

MS Visual C/C++

Linux/CentOS C/C++

Alpine Linux C/C++

MAC OS X C/C++

armhf/aarch64 C/C++

C++ Builder

iOS C/C++

Android C/C++

Win Mobile 5.0/Pocket PC 2003

Solaris C/C++

FreeBSD C/C++

OpenBSD C/C++

MinGW C/C++

#include <C_CkHttpRequestW.h>
#include <C_CkXmlW.h>
#include <C_CkHttpW.h>
#include <C_CkHttpResponseW.h>

void ChilkatSample(void)
    {
    HCkHttpRequestW req;
    HCkXmlW xmlCred;
    HCkXmlW xml;
    HCkHttpW http;
    HCkHttpResponseW resp;
    const wchar_t *envelopeId;
    const wchar_t *status;
    const wchar_t *statusDateTime;
    const wchar_t *uri;

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

    req = CkHttpRequestW_Create();

    CkHttpRequestW_putHttpVerb(req,L"POST");

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

    CkHttpRequestW_AddHeader(req,L"Accept",L"application/xml");

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

    xmlCred = CkXmlW_Create();
    CkXmlW_putTag(xmlCred,L"DocuSignCredentials");
    CkXmlW_UpdateChildContent(xmlCred,L"Username",L"YOUR_DOCUSIGN_USERNAME");
    CkXmlW_UpdateChildContent(xmlCred,L"Password",L"YOUR_DOCUSIGN_PASSWORD");
    CkXmlW_UpdateChildContent(xmlCred,L"IntegratorKey",L"ABCD-12345678-1234-AAAA-BBBB-abcdabcdabcd");
    CkXmlW_putEmitXmlDecl(xmlCred,FALSE);
    CkXmlW_putEmitCompact(xmlCred,TRUE);
    CkHttpRequestW_AddHeader(req,L"X-DocuSign-Authentication",CkXmlW_getXml(xmlCred));

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

    //  Build the XML for the 1st body part..
    xml = CkXmlW_Create();
    CkXmlW_putTag(xml,L"envelopeDefinition");
    CkXmlW_AddAttribute(xml,L"xmlns",L"http://www.docusign.com/restapi");
    CkXmlW_UpdateChildContent(xml,L"emailSubject",L"Signature Request: Test Test:001019:033611");
    CkXmlW_UpdateChildContent(xml,L"status",L"sent");
    CkXmlW_UpdateChildContent(xml,L"documents|document|documentId",L"1");
    CkXmlW_UpdateChildContent(xml,L"documents|document|name",L"001019_TestTest_RetailDeals_163357");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|hostEmail",L"admin@chilkatsoft.com");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|hostName",L"Chilkat Admin");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|signerName",L"Test  Test");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|recipientId",L"1");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|routingOrder",L"1");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|signerEmail",L"test@tyest.com");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere|anchorIgnoreIfNotPresent",L"True");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere|anchorString",L"\\SDP");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere|optional",L"False");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[1]|anchorIgnoreIfNotPresent",L"True");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[1]|anchorString",L"\\OSDP");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[1]|optional",L"True");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[2]|anchorIgnoreIfNotPresent",L"True");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[2]|anchorString",L"\\OPSSDP");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[2]|optional",L"True");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[2]|scaleValue",L"0.7");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[3]|anchorIgnoreIfNotPresent",L"True");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[3]|anchorString",L"\\PSSDP");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[3]|optional",L"False");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[3]|scaleValue",L"0.7");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere|anchorIgnoreIfNotPresent",L"True");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere|anchorString",L"\\IDP");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere|optional",L"False");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[1]|anchorIgnoreIfNotPresent",L"True");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[1]|anchorString",L"\\OIDP");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[1]|optional",L"True");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[2]|anchorIgnoreIfNotPresent",L"True");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[2]|anchorString",L"\\OPSIDP");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[2]|optional",L"True");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[2]|scaleValue",L"0.5");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[3]|anchorIgnoreIfNotPresent",L"True");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[3]|anchorString",L"\\PSIDP");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[3]|optional",L"False");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[3]|scaleValue",L"0.5");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner[1]|hostEmail",L"admin@chilkatsoft.com");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner[1]|hostName",L"Chilkat Admin");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner[1]|signerName",L"Dealer Representative");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner[1]|recipientId",L"2");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner[1]|routingOrder",L"2");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere|anchorIgnoreIfNotPresent",L"True");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere|anchorString",L"\\DSDP");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere|optional",L"False");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere[1]|anchorIgnoreIfNotPresent",L"True");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere[1]|anchorString",L"\\DOSDP");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere[1]|optional",L"True");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere|anchorIgnoreIfNotPresent",L"True");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere|anchorString",L"\\DIDP");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere|optional",L"False");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere[1]|anchorIgnoreIfNotPresent",L"True");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere[1]|anchorString",L"\\DOIDP");
    CkXmlW_UpdateChildContent(xml,L"recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere[1]|optional",L"True");
    CkXmlW_putEmitXmlDecl(xml,FALSE);

    wprintf(L"%s\n",CkXmlW_getXml(xml));

    CkXmlW_putEmitCompact(xml,TRUE);

    //  IMPORTANT: This example requires Chilkat v9.5.0.75 or greater.
    CkHttpRequestW_AddStringForUpload2(req,L"",L"",CkXmlW_getXml(xml),L"utf-8",L"application/xml");
    CkHttpRequestW_AddFileForUpload2(req,L"",L"qa_data/pdf/signatureForm.pdf",L"application/pdf");
    CkHttpRequestW_AddSubHeader(req,1,L"Content-Disposition",L"file; filename=\"signatureForm.pdf\";documentid=1");

    http = CkHttpW_Create();

    CkHttpW_putSessionLogFilename(http,L"qa_output/log.txt");

    resp = CkHttpW_SynchronousRequest(http,L"na2.docusign.net",443,TRUE,req);
    if (CkHttpW_getLastMethodSuccess(http) != TRUE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpRequestW_Dispose(req);
        CkXmlW_Dispose(xmlCred);
        CkXmlW_Dispose(xml);
        CkHttpW_Dispose(http);
        return;
    }

    if (CkHttpResponseW_getStatusCode(resp) != 201) {
        wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
        wprintf(L"Response status code: %d\n",CkHttpResponseW_getStatusCode(resp));
        wprintf(L"Failed.\n");
        CkHttpResponseW_Dispose(resp);
        CkHttpRequestW_Dispose(req);
        CkXmlW_Dispose(xmlCred);
        CkXmlW_Dispose(xml);
        CkHttpW_Dispose(http);
        return;
    }

    //  Examine the response..
    CkXmlW_LoadXml(xml,CkHttpResponseW_bodyStr(resp));
    envelopeId = CkXmlW_getChildContent(xml,L"envelopeId");
    wprintf(L"envelopeId = %s\n",envelopeId);
    status = CkXmlW_getChildContent(xml,L"status");
    wprintf(L"status = %s\n",status);
    statusDateTime = CkXmlW_getChildContent(xml,L"statusDateTime");
    wprintf(L"statusDateTime = %s\n",statusDateTime);
    uri = CkXmlW_getChildContent(xml,L"uri");
    wprintf(L"uri = %s\n",uri);

    CkHttpResponseW_Dispose(resp);


    CkHttpRequestW_Dispose(req);
    CkXmlW_Dispose(xmlCred);
    CkXmlW_Dispose(xml);
    CkHttpW_Dispose(http);

    }

 

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