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
(PowerBuilder) DocuSign: Requesting a Signature via Email (Remote Signing)See more DocuSign ExamplesThis code example demonstrates the simplest and quickest workflow for requesting a signature for a document via email. The email will contain a signing link the recipient can use to electronically sign a document from their mobile or desktop computer. For more information, see https://developers.docusign.com/esign-rest-api/code-examples/quickstart-request-signature-email
integer li_rc oleobject loo_Http integer li_Success oleobject loo_PdfData oleobject loo_Json oleobject loo_JsonToken oleobject loo_SbAuth oleobject loo_Resp oleobject loo_SbResponseBody oleobject loo_JResp integer li_RespStatusCode string ls_EnvelopeId string ls_Uri string ls_StatusDateTime string ls_Status // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_Http = create oleobject // Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 li_rc = loo_Http.ConnectToNewObject("Chilkat.Http") if li_rc < 0 then destroy loo_Http MessageBox("Error","Connecting to COM object failed") return end if // Implements the following CURL command: // curl --request POST https://demo.docusign.net/restapi/v2.1/accounts/${accountId}/envelopes \ // --header "Authorization: Bearer ${accessToken}" \ // --header "Content-Type: application/json" \ // --data '{ // "emailSubject": "Please sign this document", // "documents": [ // { // "documentBase64": "JVBERi0xLjMKMyAwIG9iag ... dGFydHhyZWYKNjk5CiUlRU9GCg==", // "name": "Lorem Ipsum", // "fileExtension": "pdf", // "documentId": "1" // } // ], // "recipients": { // "signers": [ // { // "email": "joe_sample@example.com", // "name": "Joe Sample", // "recipientId": "1", // "routingOrder": "1", // "tabs": { // "signHereTabs": [ // { // "documentId": "1", "pageNumber": "1", // "recipientId": "1", "tabLabel": "SignHereTab", // "xPosition": "195", "yPosition": "147" // } // ] // } // } // ] // }, // "status": "sent" // }' // Use this online tool to generate code from sample JSON: // Generate Code to Create JSON // The following JSON is sent in the request body. // { // "emailSubject": "Please sign this document", // "documents": [ // { // "documentBase64": "JVBERi0xLjMKMyAwIG9iag ... dGFydHhyZWYKNjk5CiUlRU9GCg==", // "name": "Lorem Ipsum", // "fileExtension": "pdf", // "documentId": "1" // } // ], // "recipients": { // "signers": [ // { // "email": "joe_sample@example.com", // "name": "Joe Sample", // "recipientId": "1", // "routingOrder": "1", // "tabs": { // "signHereTabs": [ // { // "documentId": "1", // "pageNumber": "1", // "recipientId": "1", // "tabLabel": "SignHereTab", // "xPosition": "195", // "yPosition": "147" // } // ] // } // } // ] // }, // "status": "sent" // } // Load a PDF to be signed. loo_PdfData = create oleobject // Use "Chilkat_9_5_0.BinData" for versions of Chilkat < 10.0.0 li_rc = loo_PdfData.ConnectToNewObject("Chilkat.BinData") li_Success = loo_PdfData.LoadFile("qa_data/pdf/helloWorld.pdf") if li_Success = 0 then Write-Debug "Failed to load local PDF file." destroy loo_Http destroy loo_PdfData return end if loo_Json = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject") loo_Json.UpdateString("emailSubject","Please sign this document") loo_Json.UpdateString("documents[0].documentBase64",loo_PdfData.GetEncoded("base64")) loo_Json.UpdateString("documents[0].name","Lorem Ipsum") loo_Json.UpdateString("documents[0].fileExtension","pdf") loo_Json.UpdateString("documents[0].documentId","1") loo_Json.UpdateString("recipients.signers[0].email","joe_sample@example.com") loo_Json.UpdateString("recipients.signers[0].name","Joe Sample") loo_Json.UpdateString("recipients.signers[0].recipientId","1") loo_Json.UpdateString("recipients.signers[0].routingOrder","1") loo_Json.UpdateString("recipients.signers[0].tabs.signHereTabs[0].documentId","1") loo_Json.UpdateString("recipients.signers[0].tabs.signHereTabs[0].pageNumber","1") loo_Json.UpdateString("recipients.signers[0].tabs.signHereTabs[0].recipientId","1") loo_Json.UpdateString("recipients.signers[0].tabs.signHereTabs[0].tabLabel","SignHereTab") loo_Json.UpdateString("recipients.signers[0].tabs.signHereTabs[0].xPosition","195") loo_Json.UpdateString("recipients.signers[0].tabs.signHereTabs[0].yPosition","147") loo_Json.UpdateString("status","sent") // Get our previously obtained OAuth2 access token, which should contain JSON like this: // { // "access_token": "eyJ0eXA....YQyig", // "token_type": "Bearer", // "refresh_token": "eyJ0eXA....auE3eHKg", // "expires_in": 28800 // } loo_JsonToken = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_JsonToken.ConnectToNewObject("Chilkat.JsonObject") li_Success = loo_JsonToken.LoadFile("qa_data/tokens/docusign.json") loo_SbAuth = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbAuth.ConnectToNewObject("Chilkat.StringBuilder") loo_SbAuth.Append("Bearer ") loo_SbAuth.Append(loo_JsonToken.StringOf("access_token")) loo_Http.SetRequestHeader("Authorization",loo_SbAuth.GetAsString()) loo_Http.SetRequestHeader("Content-Type","application/json") // Don't forget to modify this line to use your account ID loo_Resp = loo_Http.PostJson3("https://demo.docusign.net/restapi/v2.1/accounts/${accountId}/envelopes","application/json",loo_Json) if loo_Http.LastMethodSuccess = 0 then Write-Debug loo_Http.LastErrorText destroy loo_Http destroy loo_PdfData destroy loo_Json destroy loo_JsonToken destroy loo_SbAuth return end if loo_SbResponseBody = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder") loo_Resp.GetBodySb(loo_SbResponseBody) loo_JResp = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject") loo_JResp.LoadSb(loo_SbResponseBody) loo_JResp.EmitCompact = 0 Write-Debug "Response Body:" Write-Debug loo_JResp.Emit() li_RespStatusCode = loo_Resp.StatusCode Write-Debug "Response Status Code = " + string(li_RespStatusCode) if li_RespStatusCode >= 400 then Write-Debug "Response Header:" Write-Debug loo_Resp.Header Write-Debug "Failed." destroy loo_Resp destroy loo_Http destroy loo_PdfData destroy loo_Json destroy loo_JsonToken destroy loo_SbAuth destroy loo_SbResponseBody destroy loo_JResp return end if destroy loo_Resp // Sample JSON response: // (Sample code for parsing the JSON response is shown below) // { // "envelopeId": "d51cfdab-22ed-4832-bf68-446c44077ffc", // "uri": "/envelopes/d51cfdab-22ed-4832-bf68-446c44077ffc", // "statusDateTime": "2018-04-17T16:31:51.8830000Z", // "status": "sent" // } // Sample code for parsing the JSON response... // Use the following online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON ls_EnvelopeId = loo_JResp.StringOf("envelopeId") ls_Uri = loo_JResp.StringOf("uri") ls_StatusDateTime = loo_JResp.StringOf("statusDateTime") ls_Status = loo_JResp.StringOf("status") destroy loo_Http destroy loo_PdfData destroy loo_Json destroy loo_JsonToken destroy loo_SbAuth destroy loo_SbResponseBody destroy loo_JResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.