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
(Swift 3,4,5...) Send DocuSign XML RequestDemonstrates how to send a DocuSign XML request. Important:This example requires Chillkat v9.5.0.75 or greater.
func chilkatTest() { // This requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. let req = CkoHttpRequest()! req.httpVerb = "POST" // Replace "12999999" with your own account number. (12999999 is a ficticious account number) req.path = "/restapi/v2/accounts/12999999/envelopes" req.addHeader("Accept", value: "application/xml") // Don't worry about the boundary string. Chilkat will automatically generate one and include it. req.contentType = "multipart/form-data" let xmlCred = CkoXml()! xmlCred.tag = "DocuSignCredentials" xmlCred.updateChildContent("Username", value: "YOUR_DOCUSIGN_USERNAME") xmlCred.updateChildContent("Password", value: "YOUR_DOCUSIGN_PASSWORD") xmlCred.updateChildContent("IntegratorKey", value: "ABCD-12345678-1234-AAAA-BBBB-abcdabcdabcd") xmlCred.emitXmlDecl = false xmlCred.emitCompact = true req.addHeader("X-DocuSign-Authentication", value: xmlCred.getXml()) // Don't worry about Host or Content-Length headers, Chilkat automatically adds them... // Build the XML for the 1st body part.. let xml = CkoXml()! xml.tag = "envelopeDefinition" xml.addAttribute("xmlns", value: "http://www.docusign.com/restapi") xml.updateChildContent("emailSubject", value: "Signature Request: Test Test:001019:033611") xml.updateChildContent("status", value: "sent") xml.updateChildContent("documents|document|documentId", value: "1") xml.updateChildContent("documents|document|name", value: "001019_TestTest_RetailDeals_163357") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|hostEmail", value: "admin@chilkatsoft.com") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|hostName", value: "Chilkat Admin") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|signerName", value: "Test Test") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|recipientId", value: "1") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|routingOrder", value: "1") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|signerEmail", value: "test@tyest.com") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere|anchorIgnoreIfNotPresent", value: "True") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere|anchorString", value: "\\SDP") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere|optional", value: "False") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[1]|anchorIgnoreIfNotPresent", value: "True") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[1]|anchorString", value: "\\OSDP") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[1]|optional", value: "True") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[2]|anchorIgnoreIfNotPresent", value: "True") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[2]|anchorString", value: "\\OPSSDP") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[2]|optional", value: "True") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[2]|scaleValue", value: "0.7") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[3]|anchorIgnoreIfNotPresent", value: "True") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[3]|anchorString", value: "\\PSSDP") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[3]|optional", value: "False") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|tabs|signHereTabs|signHere[3]|scaleValue", value: "0.7") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere|anchorIgnoreIfNotPresent", value: "True") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere|anchorString", value: "\\IDP") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere|optional", value: "False") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[1]|anchorIgnoreIfNotPresent", value: "True") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[1]|anchorString", value: "\\OIDP") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[1]|optional", value: "True") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[2]|anchorIgnoreIfNotPresent", value: "True") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[2]|anchorString", value: "\\OPSIDP") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[2]|optional", value: "True") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[2]|scaleValue", value: "0.5") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[3]|anchorIgnoreIfNotPresent", value: "True") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[3]|anchorString", value: "\\PSIDP") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[3]|optional", value: "False") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner|tabs|initialHereTabs|initialHere[3]|scaleValue", value: "0.5") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner[1]|hostEmail", value: "admin@chilkatsoft.com") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner[1]|hostName", value: "Chilkat Admin") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner[1]|signerName", value: "Dealer Representative") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner[1]|recipientId", value: "2") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner[1]|routingOrder", value: "2") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere|anchorIgnoreIfNotPresent", value: "True") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere|anchorString", value: "\\DSDP") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere|optional", value: "False") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere[1]|anchorIgnoreIfNotPresent", value: "True") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere[1]|anchorString", value: "\\DOSDP") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner[1]|tabs|signHereTabs|signHere[1]|optional", value: "True") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere|anchorIgnoreIfNotPresent", value: "True") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere|anchorString", value: "\\DIDP") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere|optional", value: "False") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere[1]|anchorIgnoreIfNotPresent", value: "True") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere[1]|anchorString", value: "\\DOIDP") xml.updateChildContent("recipients|inPersonSigners|inPersonSigner[1]|tabs|initialHereTabs|initialHere[1]|optional", value: "True") xml.emitXmlDecl = false print("\(xml.getXml()!)") xml.emitCompact = true // IMPORTANT: This example requires Chilkat v9.5.0.75 or greater. req.addString(forUpload2: "", filename: "", strData: xml.getXml(), charset: "utf-8", contentType: "application/xml") req.addFile(forUpload2: "", path: "qa_data/pdf/signatureForm.pdf", contentType: "application/pdf") req.addSubHeader(1, name: "Content-Disposition", value: "file; filename=\"signatureForm.pdf\";documentid=1") let http = CkoHttp()! http.sessionLogFilename = "qa_output/log.txt" var resp: CkoHttpResponse? = http.synchronousRequest("na2.docusign.net", port: 443, ssl: true, req: req) if http.lastMethodSuccess != true { print("\(http.lastErrorText!)") return } if resp!.statusCode.intValue != 201 { print("\(resp!.bodyStr!)") print("Response status code: \(resp!.statusCode.intValue)") print("Failed.") resp = nil return } // Examine the response.. xml.load(resp!.bodyStr) var envelopeId: String? = xml.getChildContent("envelopeId") print("envelopeId = \(envelopeId!)") var status: String? = xml.getChildContent("status") print("status = \(status!)") var statusDateTime: String? = xml.getChildContent("statusDateTime") print("statusDateTime = \(statusDateTime!)") var uri: String? = xml.getChildContent("uri") print("uri = \(uri!)") resp = nil } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.