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
(Unicode C) Send DocuSign XML RequestDemonstrates how to send a DocuSign XML request. Important:This example requires Chillkat v9.5.0.75 or greater.
#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-2024 Chilkat Software, Inc. All Rights Reserved.