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
(Delphi DLL) Send DocuSign XML RequestDemonstrates how to send a DocuSign XML request. Important:This example requires Chillkat v9.5.0.75 or greater.
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Http, HttpRequest, HttpResponse, Xml; ... procedure TForm1.Button1Click(Sender: TObject); var req: HCkHttpRequest; xmlCred: HCkXml; xml: HCkXml; http: HCkHttp; resp: HCkHttpResponse; envelopeId: PWideChar; status: PWideChar; statusDateTime: PWideChar; uri: PWideChar; begin // 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); Memo1.Lines.Add(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) then begin Memo1.Lines.Add(CkHttp__lastErrorText(http)); Exit; end; if (CkHttpResponse_getStatusCode(resp) <> 201) then begin Memo1.Lines.Add(CkHttpResponse__bodyStr(resp)); Memo1.Lines.Add('Response status code: ' + IntToStr(CkHttpResponse_getStatusCode(resp))); Memo1.Lines.Add('Failed.'); CkHttpResponse_Dispose(resp); Exit; end; // Examine the response.. CkXml_LoadXml(xml,CkHttpResponse__bodyStr(resp)); envelopeId := CkXml__getChildContent(xml,'envelopeId'); Memo1.Lines.Add('envelopeId = ' + envelopeId); status := CkXml__getChildContent(xml,'status'); Memo1.Lines.Add('status = ' + status); statusDateTime := CkXml__getChildContent(xml,'statusDateTime'); Memo1.Lines.Add('statusDateTime = ' + statusDateTime); uri := CkXml__getChildContent(xml,'uri'); Memo1.Lines.Add('uri = ' + uri); CkHttpResponse_Dispose(resp); CkHttpRequest_Dispose(req); CkXml_Dispose(xmlCred); CkXml_Dispose(xml); CkHttp_Dispose(http); end; |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.