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
(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_CkHttpRequest.h> #include <C_CkXml.h> #include <C_CkHttp.h> #include <C_CkHttpResponse.h> void ChilkatSample(void) { HCkHttpRequest req; HCkXml xmlCred; HCkXml xml; HCkHttp http; HCkHttpResponse resp; const char *envelopeId; const char *status; const char *statusDateTime; const char *uri; // This requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. req = CkHttpRequest_Create(); CkHttpRequest_putHttpVerb(req,"POST"); // Replace "12999999" with your own account number. (12999999 is a ficticious account number) CkHttpRequest_putPath(req,"/restapi/v2/accounts/12999999/envelopes"); CkHttpRequest_AddHeader(req,"Accept","application/xml"); // Don't worry about the boundary string. Chilkat will automatically generate one and include it. CkHttpRequest_putContentType(req,"multipart/form-data"); xmlCred = CkXml_Create(); CkXml_putTag(xmlCred,"DocuSignCredentials"); CkXml_UpdateChildContent(xmlCred,"Username","YOUR_DOCUSIGN_USERNAME"); CkXml_UpdateChildContent(xmlCred,"Password","YOUR_DOCUSIGN_PASSWORD"); CkXml_UpdateChildContent(xmlCred,"IntegratorKey","ABCD-12345678-1234-AAAA-BBBB-abcdabcdabcd"); CkXml_putEmitXmlDecl(xmlCred,FALSE); CkXml_putEmitCompact(xmlCred,TRUE); CkHttpRequest_AddHeader(req,"X-DocuSign-Authentication",CkXml_getXml(xmlCred)); // Don't worry about Host or Content-Length headers, Chilkat automatically adds them... // Build the XML for the 1st body part.. xml = CkXml_Create(); CkXml_putTag(xml,"envelopeDefinition"); CkXml_AddAttribute(xml,"xmlns","http://www.docusign.com/restapi"); CkXml_UpdateChildContent(xml,"emailSubject","Signature Request: Test Test:001019:033611"); CkXml_UpdateChildContent(xml,"status","sent"); CkXml_UpdateChildContent(xml,"documents|document|documentId","1"); CkXml_UpdateChildContent(xml,"documents|document|name","001019_TestTest_RetailDeals_163357"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|hostEmail","admin@chilkatsoft.com"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|hostName","Chilkat Admin"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|signerName","Test Test"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|recipientId","1"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|routingOrder","1"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|signerEmail","test@tyest.com"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere|anchorIgnoreIfNotPresent","True"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere|anchorString","\\SDP"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere|optional","False"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[1]|anchorIgnoreIfNotPresent","True"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[1]|anchorString","\\OSDP"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[1]|optional","True"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[2]|anchorIgnoreIfNotPresent","True"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[2]|anchorString","\\OPSSDP"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[2]|optional","True"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[2]|scaleValue","0.7"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[3]|anchorIgnoreIfNotPresent","True"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[3]|anchorString","\\PSSDP"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[3]|optional","False"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[3]|scaleValue","0.7"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere|anchorIgnoreIfNotPresent","True"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere|anchorString","\\IDP"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere|optional","False"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[1]|anchorIgnoreIfNotPresent","True"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[1]|anchorString","\\OIDP"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[1]|optional","True"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[2]|anchorIgnoreIfNotPresent","True"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[2]|anchorString","\\OPSIDP"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[2]|optional","True"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[2]|scaleValue","0.5"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[3]|anchorIgnoreIfNotPresent","True"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[3]|anchorString","\\PSIDP"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[3]|optional","False"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[3]|scaleValue","0.5"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|hostEmail","admin@chilkatsoft.com"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|hostName","Chilkat Admin"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|signerName","Dealer Representative"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|recipientId","2"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|routingOrder","2"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere|anchorIgnoreIfNotPresent","True"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere|anchorString","\\DSDP"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere|optional","False"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere[1]|anchorIgnoreIfNotPresent","True"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere[1]|anchorString","\\DOSDP"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere[1]|optional","True"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere|anchorIgnoreIfNotPresent","True"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere|anchorString","\\DIDP"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere|optional","False"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere[1]|anchorIgnoreIfNotPresent","True"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere[1]|anchorString","\\DOIDP"); CkXml_UpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere[1]|optional","True"); CkXml_putEmitXmlDecl(xml,FALSE); printf("%s\n",CkXml_getXml(xml)); CkXml_putEmitCompact(xml,TRUE); // IMPORTANT: This example requires Chilkat v9.5.0.75 or greater. CkHttpRequest_AddStringForUpload2(req,"","",CkXml_getXml(xml),"utf-8","application/xml"); CkHttpRequest_AddFileForUpload2(req,"","qa_data/pdf/signatureForm.pdf","application/pdf"); CkHttpRequest_AddSubHeader(req,1,"Content-Disposition","file; filename=\"signatureForm.pdf\";documentid=1"); http = CkHttp_Create(); CkHttp_putSessionLogFilename(http,"qa_output/log.txt"); resp = CkHttp_SynchronousRequest(http,"na2.docusign.net",443,TRUE,req); if (CkHttp_getLastMethodSuccess(http) != TRUE) { printf("%s\n",CkHttp_lastErrorText(http)); CkHttpRequest_Dispose(req); CkXml_Dispose(xmlCred); CkXml_Dispose(xml); CkHttp_Dispose(http); return; } if (CkHttpResponse_getStatusCode(resp) != 201) { printf("%s\n",CkHttpResponse_bodyStr(resp)); printf("Response status code: %d\n",CkHttpResponse_getStatusCode(resp)); printf("Failed.\n"); CkHttpResponse_Dispose(resp); CkHttpRequest_Dispose(req); CkXml_Dispose(xmlCred); CkXml_Dispose(xml); CkHttp_Dispose(http); return; } // Examine the response.. CkXml_LoadXml(xml,CkHttpResponse_bodyStr(resp)); envelopeId = CkXml_getChildContent(xml,"envelopeId"); printf("envelopeId = %s\n",envelopeId); status = CkXml_getChildContent(xml,"status"); printf("status = %s\n",status); statusDateTime = CkXml_getChildContent(xml,"statusDateTime"); printf("statusDateTime = %s\n",statusDateTime); uri = CkXml_getChildContent(xml,"uri"); printf("uri = %s\n",uri); CkHttpResponse_Dispose(resp); CkHttpRequest_Dispose(req); CkXml_Dispose(xmlCred); CkXml_Dispose(xml); CkHttp_Dispose(http); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.