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 Add Recipients to a Draft EnvelopeSee more DocuSign ExamplesDemonstrates how to add one or more recipients to a DocuSign draft envelope. For more information, see https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/enveloperecipients/create/
integer li_rc oleobject loo_Http oleobject loo_JsonToken integer li_Success oleobject loo_Json integer i oleobject loo_SbJson string ls_Url oleobject loo_Resp oleobject loo_JResp integer li_RespStatusCode string ls_CreationReason string ls_RequireUploadSignature string ls_Email string ls_RecipientId string ls_RequireIdLookup string ls_RoutingOrder string ls_Status string ls_CompletedCount string ls_DeliveryMethod string ls_RecipientType string ls_RecipientCount integer li_Count_i // 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 // Load a previously obtained OAuth2 access token. 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") if li_Success = 0 then Write-Debug loo_JsonToken.LastErrorText destroy loo_Http destroy loo_JsonToken return end if // Adds the "Authorization: Bearer eyJ0eXAi.....UE8Kl_V8KroQ" header. loo_Http.AuthToken = loo_JsonToken.StringOf("access_token") // Send the following request. // Make sure to use your own account ID (obtained from Get Docusign User Account Information) // POST https://demo.docusign.net/restapi/v2.1/accounts/<account ID>/envelopes/<envelope ID>/recipients HTTP/1.1 // Accept: application/json // Cache-Control: no-cache // Authorization: Bearer eyJ0eX... // Content-Length: ... // Content-Type: application/json // // { // "carbonCopies": [ // { // "email": "support@chilkatsoft.com", // "name": "Chilkat Support", // "recipientId": "101", // "tabs": {} // } // ], // "signers": [ // { // "email": "admin@chilkatsoft.com", // "name": "Chilkat Admin", // "recipientId": "1", // "tabs": { // "signHereTabs": [{ // "anchorString": "Please Sign Here", // "anchorXOffset": "1", // "anchorYOffset": "0", // "anchorIgnoreIfNotPresent": "false", // "anchorUnits": "inches" // }] // } // }, // { // "email": "matt@chilkat.io", // "name": "Matt", // "recipientId": "2", // "tabs": { // "signHereTabs": [{ // "anchorString": "Please Also Sign Here", // "anchorXOffset": "1", // "anchorYOffset": "0", // "anchorIgnoreIfNotPresent": "false", // "anchorUnits": "inches" // }] // } // } // ] // } loo_Json = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject") i = 0 loo_Json.I = i loo_Json.UpdateString("carbonCopies[i].email","support@chilkatsoft.com") loo_Json.UpdateString("carbonCopies[i].name","Chilkat Support") loo_Json.UpdateString("carbonCopies[i].recipientId","101") loo_Json.UpdateNewObject("carbonCopies[i].tabs") i = 0 loo_Json.I = i loo_Json.UpdateString("signers[i].email","admin@chilkatsoft.com") loo_Json.UpdateString("signers[i].name","Chilkat Admin") loo_Json.UpdateString("signers[i].recipientId","1") loo_Json.UpdateString("signers[i].tabs.signHereTabs[0].anchorString","Please Sign Here") loo_Json.UpdateString("signers[i].tabs.signHereTabs[0].anchorXOffset","1") loo_Json.UpdateString("signers[i].tabs.signHereTabs[0].anchorYOffset","0") loo_Json.UpdateString("signers[i].tabs.signHereTabs[0].anchorIgnoreIfNotPresent","false") loo_Json.UpdateString("signers[i].tabs.signHereTabs[0].anchorUnits","inches") i = i + 1 loo_Json.I = i loo_Json.UpdateString("signers[i].email","matt@chilkat.io") loo_Json.UpdateString("signers[i].name","Matt") loo_Json.UpdateString("signers[i].recipientId","2") loo_Json.UpdateString("signers[i].tabs.signHereTabs[0].anchorString","Please Also Sign Here") loo_Json.UpdateString("signers[i].tabs.signHereTabs[0].anchorXOffset","1") loo_Json.UpdateString("signers[i].tabs.signHereTabs[0].anchorYOffset","0") loo_Json.UpdateString("signers[i].tabs.signHereTabs[0].anchorIgnoreIfNotPresent","false") loo_Json.UpdateString("signers[i].tabs.signHereTabs[0].anchorUnits","inches") loo_SbJson = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbJson.ConnectToNewObject("Chilkat.StringBuilder") loo_Json.EmitCompact = 0 loo_Json.EmitSb(loo_SbJson) loo_Http.SetRequestHeader("Cache-Control","no-cache") loo_Http.SetRequestHeader("Accept","application/json") // Use your own account ID here. loo_Http.SetUrlVar("accountId","7f3f65ed-5e87-418d-94c1-92499ddc8252") // Use the envelope ID returned by DocuSign when creating the draft envelope). loo_Http.SetUrlVar("envelopeId","cee4191c-f94e-4089-9d7c-8033685cbc1a") ls_Url = "https://demo.docusign.net/restapi/v2.1/accounts/{$accountId}/envelopes/{$envelopeId}/recipients" loo_Resp = loo_Http.PTextSb("POST",ls_Url,loo_SbJson,"utf-8","application/json",0,0) if loo_Http.LastMethodSuccess = 0 then Write-Debug loo_Http.LastErrorText destroy loo_Http destroy loo_JsonToken destroy loo_Json destroy loo_SbJson return end if 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.Load(loo_Resp.BodyStr) loo_JResp.EmitCompact = 0 Write-Debug "Response Body:" Write-Debug loo_JResp.Emit() // If you get a 401 response status code, it's likely you need to refresh the DocuSign OAuth2 token). 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_JsonToken destroy loo_Json destroy loo_SbJson destroy loo_JResp return end if destroy loo_Resp // Sample JSON response: // (Sample code for parsing the JSON response is shown below) // { // "signers": [ // { // "creationReason": "sender", // "requireUploadSignature": "false", // "email": "admin@chilkatsoft.com", // "recipientId": "1", // "requireIdLookup": "false", // "routingOrder": "1", // "status": "created", // "completedCount": "0", // "deliveryMethod": "email", // "recipientType": "signer" // }, // { // "creationReason": "sender", // "requireUploadSignature": "false", // "email": "matt@chilkat.io", // "recipientId": "2", // "requireIdLookup": "false", // "routingOrder": "1", // "status": "created", // "completedCount": "0", // "deliveryMethod": "email", // "recipientType": "signer" // } // ], // "agents": [], // "editors": [], // "intermediaries": [], // "carbonCopies": [ // { // "email": "support@chilkatsoft.com", // "recipientId": "101", // "requireIdLookup": "false", // "routingOrder": "1", // "status": "created", // "completedCount": "0", // "deliveryMethod": "email", // "recipientType": "carboncopy" // } // ], // "certifiedDeliveries": [], // "inPersonSigners": [], // "seals": [], // "witnesses": [], // "recipientCount": "3" // } // 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_RecipientCount = loo_Json.StringOf("recipientCount") i = 0 li_Count_i = loo_Json.SizeOfArray("signers") do while i < li_Count_i loo_Json.I = i ls_CreationReason = loo_Json.StringOf("signers[i].creationReason") ls_RequireUploadSignature = loo_Json.StringOf("signers[i].requireUploadSignature") ls_Email = loo_Json.StringOf("signers[i].email") ls_RecipientId = loo_Json.StringOf("signers[i].recipientId") ls_RequireIdLookup = loo_Json.StringOf("signers[i].requireIdLookup") ls_RoutingOrder = loo_Json.StringOf("signers[i].routingOrder") ls_Status = loo_Json.StringOf("signers[i].status") ls_CompletedCount = loo_Json.StringOf("signers[i].completedCount") ls_DeliveryMethod = loo_Json.StringOf("signers[i].deliveryMethod") ls_RecipientType = loo_Json.StringOf("signers[i].recipientType") i = i + 1 loop i = 0 li_Count_i = loo_Json.SizeOfArray("agents") do while i < li_Count_i loo_Json.I = i // ... i = i + 1 loop i = 0 li_Count_i = loo_Json.SizeOfArray("editors") do while i < li_Count_i loo_Json.I = i // ... i = i + 1 loop i = 0 li_Count_i = loo_Json.SizeOfArray("intermediaries") do while i < li_Count_i loo_Json.I = i // ... i = i + 1 loop i = 0 li_Count_i = loo_Json.SizeOfArray("carbonCopies") do while i < li_Count_i loo_Json.I = i ls_Email = loo_Json.StringOf("carbonCopies[i].email") ls_RecipientId = loo_Json.StringOf("carbonCopies[i].recipientId") ls_RequireIdLookup = loo_Json.StringOf("carbonCopies[i].requireIdLookup") ls_RoutingOrder = loo_Json.StringOf("carbonCopies[i].routingOrder") ls_Status = loo_Json.StringOf("carbonCopies[i].status") ls_CompletedCount = loo_Json.StringOf("carbonCopies[i].completedCount") ls_DeliveryMethod = loo_Json.StringOf("carbonCopies[i].deliveryMethod") ls_RecipientType = loo_Json.StringOf("carbonCopies[i].recipientType") i = i + 1 loop i = 0 li_Count_i = loo_Json.SizeOfArray("certifiedDeliveries") do while i < li_Count_i loo_Json.I = i // ... i = i + 1 loop i = 0 li_Count_i = loo_Json.SizeOfArray("inPersonSigners") do while i < li_Count_i loo_Json.I = i // ... i = i + 1 loop i = 0 li_Count_i = loo_Json.SizeOfArray("seals") do while i < li_Count_i loo_Json.I = i // ... i = i + 1 loop i = 0 li_Count_i = loo_Json.SizeOfArray("witnesses") do while i < li_Count_i loo_Json.I = i // ... i = i + 1 loop // If the recipient already exists within the envelope, we would get // a success (201) response status code, but errors within the JSON response, such as this: // { // "signers": [ // { // "creationReason": "sender", // "requireUploadSignature": "false", // "email": "admin@chilkatsoft.com", // "recipientId": "1", // "requireIdLookup": "false", // "routingOrder": "1", // "status": "error", // "completedCount": "0", // "deliveryMethod": "email", // "errorDetails": { // "errorCode": "RECIPIENT_ALREADY_EXISTS_IN_ENVELOPE", // "message": "This recipientId already exists." // }, // "recipientType": "signer" // }, // { // "creationReason": "sender", // "requireUploadSignature": "false", // "email": "matt@chilkat.io", // "recipientId": "2", // "requireIdLookup": "false", // "routingOrder": "1", // "status": "error", // "completedCount": "0", // "deliveryMethod": "email", // "errorDetails": { // "errorCode": "RECIPIENT_ALREADY_EXISTS_IN_ENVELOPE", // "message": "This recipientId already exists." // }, // "recipientType": "signer" // } // ], // "agents": [ // ], // "editors": [ // ], // "intermediaries": [ // ], // "carbonCopies": [ // { // "email": "support@chilkatsoft.com", // "recipientId": "101", // "requireIdLookup": "false", // "routingOrder": "1", // "status": "error", // "completedCount": "0", // "deliveryMethod": "email", // "errorDetails": { // "errorCode": "RECIPIENT_ALREADY_EXISTS_IN_ENVELOPE", // "message": "This recipientId already exists." // }, // "recipientType": "carboncopy" // } // ], // "certifiedDeliveries": [ // ], // "inPersonSigners": [ // ], // "seals": [ // ], // "witnesses": [ // ], // "recipientCount": "3" // } // destroy loo_Http destroy loo_JsonToken destroy loo_Json destroy loo_SbJson destroy loo_JResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.