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
(PureBasic) Send DocuSign XML RequestDemonstrates how to send a DocuSign XML request. Important:This example requires Chillkat v9.5.0.75 or greater.
IncludeFile "CkHttp.pb" IncludeFile "CkXml.pb" IncludeFile "CkHttpResponse.pb" IncludeFile "CkHttpRequest.pb" Procedure ChilkatExample() ; This requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. req.i = CkHttpRequest::ckCreate() If req.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkHttpRequest::setCkHttpVerb(req, "POST") ; Replace "12999999" with your own account number. (12999999 is a ficticious account number) CkHttpRequest::setCkPath(req, "/restapi/v2/accounts/12999999/envelopes") CkHttpRequest::ckAddHeader(req,"Accept","application/xml") ; Don't worry about the boundary string. Chilkat will automatically generate one and include it. CkHttpRequest::setCkContentType(req, "multipart/form-data") xmlCred.i = CkXml::ckCreate() If xmlCred.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkXml::setCkTag(xmlCred, "DocuSignCredentials") CkXml::ckUpdateChildContent(xmlCred,"Username","YOUR_DOCUSIGN_USERNAME") CkXml::ckUpdateChildContent(xmlCred,"Password","YOUR_DOCUSIGN_PASSWORD") CkXml::ckUpdateChildContent(xmlCred,"IntegratorKey","ABCD-12345678-1234-AAAA-BBBB-abcdabcdabcd") CkXml::setCkEmitXmlDecl(xmlCred, 0) CkXml::setCkEmitCompact(xmlCred, 1) CkHttpRequest::ckAddHeader(req,"X-DocuSign-Authentication",CkXml::ckGetXml(xmlCred)) ; Don't worry about Host or Content-Length headers, Chilkat automatically adds them... ; Build the XML for the 1st body part.. xml.i = CkXml::ckCreate() If xml.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkXml::setCkTag(xml, "envelopeDefinition") CkXml::ckAddAttribute(xml,"xmlns","http://www.docusign.com/restapi") CkXml::ckUpdateChildContent(xml,"emailSubject","Signature Request: Test Test:001019:033611") CkXml::ckUpdateChildContent(xml,"status","sent") CkXml::ckUpdateChildContent(xml,"documents|document|documentId","1") CkXml::ckUpdateChildContent(xml,"documents|document|name","001019_TestTest_RetailDeals_163357") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|hostEmail","admin@chilkatsoft.com") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|hostName","Chilkat Admin") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|signerName","Test Test") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|recipientId","1") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|routingOrder","1") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|signerEmail","test@tyest.com") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere|anchorIgnoreIfNotPresent","True") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere|anchorString","\SDP") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere|optional","False") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[1]|anchorIgnoreIfNotPresent","True") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[1]|anchorString","\OSDP") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[1]|optional","True") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[2]|anchorIgnoreIfNotPresent","True") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[2]|anchorString","\OPSSDP") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[2]|optional","True") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[2]|scaleValue","0.7") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[3]|anchorIgnoreIfNotPresent","True") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[3]|anchorString","\PSSDP") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[3]|optional","False") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[3]|scaleValue","0.7") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere|anchorIgnoreIfNotPresent","True") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere|anchorString","\IDP") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere|optional","False") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[1]|anchorIgnoreIfNotPresent","True") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[1]|anchorString","\OIDP") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[1]|optional","True") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[2]|anchorIgnoreIfNotPresent","True") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[2]|anchorString","\OPSIDP") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[2]|optional","True") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[2]|scaleValue","0.5") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[3]|anchorIgnoreIfNotPresent","True") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[3]|anchorString","\PSIDP") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[3]|optional","False") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[3]|scaleValue","0.5") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|hostEmail","admin@chilkatsoft.com") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|hostName","Chilkat Admin") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|signerName","Dealer Representative") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|recipientId","2") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|routingOrder","2") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere|anchorIgnoreIfNotPresent","True") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere|anchorString","\DSDP") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere|optional","False") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere[1]|anchorIgnoreIfNotPresent","True") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere[1]|anchorString","\DOSDP") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere[1]|optional","True") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere|anchorIgnoreIfNotPresent","True") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere|anchorString","\DIDP") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere|optional","False") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere[1]|anchorIgnoreIfNotPresent","True") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere[1]|anchorString","\DOIDP") CkXml::ckUpdateChildContent(xml,"recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere[1]|optional","True") CkXml::setCkEmitXmlDecl(xml, 0) Debug CkXml::ckGetXml(xml) CkXml::setCkEmitCompact(xml, 1) ; IMPORTANT: This example requires Chilkat v9.5.0.75 or greater. CkHttpRequest::ckAddStringForUpload2(req,"","",CkXml::ckGetXml(xml),"utf-8","application/xml") CkHttpRequest::ckAddFileForUpload2(req,"","qa_data/pdf/signatureForm.pdf","application/pdf") CkHttpRequest::ckAddSubHeader(req,1,"Content-Disposition","file; filename=" + Chr(34) + "signatureForm.pdf" + Chr(34) + ";documentid=1") http.i = CkHttp::ckCreate() If http.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkHttp::setCkSessionLogFilename(http, "qa_output/log.txt") resp.i = CkHttp::ckSynchronousRequest(http,"na2.docusign.net",443,1,req) If CkHttp::ckLastMethodSuccess(http) <> 1 Debug CkHttp::ckLastErrorText(http) CkHttpRequest::ckDispose(req) CkXml::ckDispose(xmlCred) CkXml::ckDispose(xml) CkHttp::ckDispose(http) ProcedureReturn EndIf If CkHttpResponse::ckStatusCode(resp) <> 201 Debug CkHttpResponse::ckBodyStr(resp) Debug "Response status code: " + Str(CkHttpResponse::ckStatusCode(resp)) Debug "Failed." CkHttpResponse::ckDispose(resp) CkHttpRequest::ckDispose(req) CkXml::ckDispose(xmlCred) CkXml::ckDispose(xml) CkHttp::ckDispose(http) ProcedureReturn EndIf ; Examine the response.. CkXml::ckLoadXml(xml,CkHttpResponse::ckBodyStr(resp)) envelopeId.s = CkXml::ckGetChildContent(xml,"envelopeId") Debug "envelopeId = " + envelopeId status.s = CkXml::ckGetChildContent(xml,"status") Debug "status = " + status statusDateTime.s = CkXml::ckGetChildContent(xml,"statusDateTime") Debug "statusDateTime = " + statusDateTime uri.s = CkXml::ckGetChildContent(xml,"uri") Debug "uri = " + uri CkHttpResponse::ckDispose(resp) CkHttpRequest::ckDispose(req) CkXml::ckDispose(xmlCred) CkXml::ckDispose(xml) CkHttp::ckDispose(http) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.