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 <CkHttpRequestW.h> #include <CkXmlW.h> #include <CkHttpW.h> #include <CkHttpResponseW.h> void ChilkatSample(void) { // This requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. CkHttpRequestW req; req.put_HttpVerb(L"POST"); // Replace "12999999" with your own account number. (12999999 is a ficticious account number) req.put_Path(L"/restapi/v2/accounts/12999999/envelopes"); req.AddHeader(L"Accept",L"application/xml"); // Don't worry about the boundary string. Chilkat will automatically generate one and include it. req.put_ContentType(L"multipart/form-data"); CkXmlW xmlCred; xmlCred.put_Tag(L"DocuSignCredentials"); xmlCred.UpdateChildContent(L"Username",L"YOUR_DOCUSIGN_USERNAME"); xmlCred.UpdateChildContent(L"Password",L"YOUR_DOCUSIGN_PASSWORD"); xmlCred.UpdateChildContent(L"IntegratorKey",L"ABCD-12345678-1234-AAAA-BBBB-abcdabcdabcd"); xmlCred.put_EmitXmlDecl(false); xmlCred.put_EmitCompact(true); req.AddHeader(L"X-DocuSign-Authentication",xmlCred.getXml()); // Don't worry about Host or Content-Length headers, Chilkat automatically adds them... // Build the XML for the 1st body part.. CkXmlW xml; xml.put_Tag(L"envelopeDefinition"); xml.AddAttribute(L"xmlns",L"http://www.docusign.com/restapi"); xml.UpdateChildContent(L"emailSubject",L"Signature Request: Test Test:001019:033611"); xml.UpdateChildContent(L"status",L"sent"); xml.UpdateChildContent(L"documents|document|documentId",L"1"); xml.UpdateChildContent(L"documents|document|name",L"001019_TestTest_RetailDeals_163357"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|hostEmail",L"admin@chilkatsoft.com"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|hostName",L"Chilkat Admin"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|signerName",L"Test Test"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|recipientId",L"1"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|routingOrder",L"1"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|signerEmail",L"test@tyest.com"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere|anchorIgnoreIfNotPresent",L"True"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere|anchorString",L"\\SDP"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere|optional",L"False"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[1]|anchorIgnoreIfNotPresent",L"True"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[1]|anchorString",L"\\OSDP"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[1]|optional",L"True"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[2]|anchorIgnoreIfNotPresent",L"True"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[2]|anchorString",L"\\OPSSDP"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[2]|optional",L"True"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[2]|scaleValue",L"0.7"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[3]|anchorIgnoreIfNotPresent",L"True"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[3]|anchorString",L"\\PSSDP"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[3]|optional",L"False"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[3]|scaleValue",L"0.7"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere|anchorIgnoreIfNotPresent",L"True"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere|anchorString",L"\\IDP"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere|optional",L"False"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[1]|anchorIgnoreIfNotPresent",L"True"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[1]|anchorString",L"\\OIDP"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[1]|optional",L"True"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[2]|anchorIgnoreIfNotPresent",L"True"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[2]|anchorString",L"\\OPSIDP"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[2]|optional",L"True"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[2]|scaleValue",L"0.5"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[3]|anchorIgnoreIfNotPresent",L"True"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[3]|anchorString",L"\\PSIDP"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[3]|optional",L"False"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[3]|scaleValue",L"0.5"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner[1]|hostEmail",L"admin@chilkatsoft.com"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner[1]|hostName",L"Chilkat Admin"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner[1]|signerName",L"Dealer Representative"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner[1]|recipientId",L"2"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner[1]|routingOrder",L"2"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere|anchorIgnoreIfNotPresent",L"True"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere|anchorString",L"\\DSDP"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere|optional",L"False"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere[1]|anchorIgnoreIfNotPresent",L"True"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere[1]|anchorString",L"\\DOSDP"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere[1]|optional",L"True"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere|anchorIgnoreIfNotPresent",L"True"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere|anchorString",L"\\DIDP"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere|optional",L"False"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere[1]|anchorIgnoreIfNotPresent",L"True"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere[1]|anchorString",L"\\DOIDP"); xml.UpdateChildContent(L"recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere[1]|optional",L"True"); xml.put_EmitXmlDecl(false); wprintf(L"%s\n",xml.getXml()); xml.put_EmitCompact(true); // IMPORTANT: This example requires Chilkat v9.5.0.75 or greater. req.AddStringForUpload2(L"",L"",xml.getXml(),L"utf-8",L"application/xml"); req.AddFileForUpload2(L"",L"qa_data/pdf/signatureForm.pdf",L"application/pdf"); req.AddSubHeader(1,L"Content-Disposition",L"file; filename=\"signatureForm.pdf\";documentid=1"); CkHttpW http; http.put_SessionLogFilename(L"qa_output/log.txt"); CkHttpResponseW *resp = http.SynchronousRequest(L"na2.docusign.net",443,true,req); if (http.get_LastMethodSuccess() != true) { wprintf(L"%s\n",http.lastErrorText()); return; } if (resp->get_StatusCode() != 201) { wprintf(L"%s\n",resp->bodyStr()); wprintf(L"Response status code: %d\n",resp->get_StatusCode()); wprintf(L"Failed.\n"); delete resp; return; } // Examine the response.. xml.LoadXml(resp->bodyStr()); const wchar_t *envelopeId = xml.getChildContent(L"envelopeId"); wprintf(L"envelopeId = %s\n",envelopeId); const wchar_t *status = xml.getChildContent(L"status"); wprintf(L"status = %s\n",status); const wchar_t *statusDateTime = xml.getChildContent(L"statusDateTime"); wprintf(L"statusDateTime = %s\n",statusDateTime); const wchar_t *uri = xml.getChildContent(L"uri"); wprintf(L"uri = %s\n",uri); delete resp; } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.