使用 Chilkat dll 的 DocuSign,如何在 json 中传递 templateRoles?
DocuSign using Chilkat dll, how do I pass templateRoles in json?
我正在创建 Docusing 动态传递文件和签名者的演示应用程序,为此我需要使用 docusign templateid 并传递详细信息,我可以使用 templateid 传递文件,签名者已经在模板本身中定义,现在我想传递多个需要使用 templateRoles 的 dynamically.For 签名者。
Dim json As New Chilkat.JsonObject
json.UpdateString("documents[0].name", "Testing.pdf")
json.UpdateString("documents[0].documentBase64", base64String)
json.UpdateString("documents[0].documentId", "2")
json.UpdateString("emailSubject", "DocuSign REST API Testing Sample")
json.UpdateString("emailBlurb", "Create and send an envelope from a document.")
json.UpdateString("templateId", "xxxxx-xxxxx-xxxxx-xxxx-xxxx")
json.UpdateString("templateRoles", "{roleName: Signer 1, name: Aravind, email: aravind@gmail.com, recipientId: 1}") ' Here i pass template role for signer 1, and also need to pass multiple signer.
json.UpdateString("status", "sent")
rest.AddHeader("X-DocuSign-Authentication", "{ ""Username"": ""DocuSign@example.com"", ""Password"":""DocuSign_password"", ""IntegratorKey"":""DocuSign_Integrator_Key"" }")
rest.AddHeader("Content-Type", "application/json")
rest.AddHeader("Accept", "application/json")
Dim sbRequestBody As New Chilkat.StringBuilder
json.EmitSb(sbRequestBody)
Dim sbResponseBody As New Chilkat.StringBuilder
success = rest.FullRequestSb("POST", "/restapi/v2.1/accounts/xxxxxx/envelopes", sbRequestBody, sbResponseBody)
Dim respStatusCode As Integer = rest.ResponseStatusCode
我在这里粘贴代码供您参考,在该电子邮件、密码、密钥中我更改的所有内容,因为出于安全目的,它已重新发布。
当我传递带有值的模板角色时,我在代码上方得到 error.For 我从 api.
得到以下错误 return
"errorCode":"INVALID_REQUEST_PARAMETER","message":"The request
contained at least one invalid parameter. 'recipientId' not set for
recipient."
请帮我解决这个错误。
此致,
亚拉文
尝试从第 8 行的 JSON 中删除 recipientId: 1
。
但我强烈建议您重新考虑您的架构选择。
您正在使用不太安全的旧版身份验证。
您可以使用 C# SDK,它是一个 Nuget 包,与 VB.NET 一起工作得很好,这将帮助您在不使用 JSON 和使用现代 OAuth 的情况下进行这些调用更安全。
这是使用 SDK 的代码:
Imports System
Imports System.Collections.Generic
Imports DocuSign.eSign.Api
Imports DocuSign.eSign.Client
Imports DocuSign.eSign.Model
Imports Microsoft.AspNetCore.Mvc
Private Function DoWork(ByVal signerEmail As String, ByVal signerName As String, ByVal ccEmail As String, ByVal ccName As String, ByVal accessToken As String, ByVal basePath As String, ByVal accountId As String, ByVal templateId As String) As String
Dim config = New Configuration(New ApiClient(basePath))
config.AddDefaultHeader("Authorization", "Bearer " & accessToken)
Dim envelopesApi As EnvelopesApi = New EnvelopesApi(config)
Dim envelope As EnvelopeDefinition = MakeEnvelope(signerEmail, signerName, ccEmail, ccName, templateId)
Dim result As EnvelopeSummary = envelopesApi.CreateEnvelope(accountId, envelope)
Return result.EnvelopeId
End Function
Private Function MakeEnvelope(ByVal signerEmail As String, ByVal signerName As String) As EnvelopeDefinition
Dim buffer As Byte() = System.IO.File.ReadAllBytes(Config.docPdf)
Dim envelopeDefinition As EnvelopeDefinition = New EnvelopeDefinition()
envelopeDefinition.EmailSubject = "Please sign this document"
Dim doc1 As Document = New Document()
Dim doc1b64 As String = Convert.ToBase64String(buffer)
doc1.DocumentBase64 = doc1b64
doc1.Name = "Lorem Ipsum"
doc1.FileExtension = "pdf"
doc1.DocumentId = "3"
envelopeDefinition.Documents = New List(Of Document) From {
doc1
}
Dim signer1 As Signer = New Signer With {
.Email = signerEmail,
.Name = signerName,
.ClientUserId = signerClientId,
.RecipientId = "1"
}
Dim signHere1 As SignHere = New SignHere With {
.AnchorString = "/sn1/",
.AnchorUnits = "pixels",
.AnchorXOffset = "10",
.AnchorYOffset = "20"
}
Dim signer1Tabs As Tabs = New Tabs With {
.SignHereTabs = New List(Of SignHere) From {
signHere1
}
}
signer1.Tabs = signer1Tabs
Dim recipients As Recipients = New Recipients With {
.Signers = New List(Of Signer) From {
signer1
}
}
envelopeDefinition.Recipients = recipients
envelopeDefinition.Status = "sent"
Return envelopeDefinition
End Function
我正在创建 Docusing 动态传递文件和签名者的演示应用程序,为此我需要使用 docusign templateid 并传递详细信息,我可以使用 templateid 传递文件,签名者已经在模板本身中定义,现在我想传递多个需要使用 templateRoles 的 dynamically.For 签名者。
Dim json As New Chilkat.JsonObject
json.UpdateString("documents[0].name", "Testing.pdf")
json.UpdateString("documents[0].documentBase64", base64String)
json.UpdateString("documents[0].documentId", "2")
json.UpdateString("emailSubject", "DocuSign REST API Testing Sample")
json.UpdateString("emailBlurb", "Create and send an envelope from a document.")
json.UpdateString("templateId", "xxxxx-xxxxx-xxxxx-xxxx-xxxx")
json.UpdateString("templateRoles", "{roleName: Signer 1, name: Aravind, email: aravind@gmail.com, recipientId: 1}") ' Here i pass template role for signer 1, and also need to pass multiple signer.
json.UpdateString("status", "sent")
rest.AddHeader("X-DocuSign-Authentication", "{ ""Username"": ""DocuSign@example.com"", ""Password"":""DocuSign_password"", ""IntegratorKey"":""DocuSign_Integrator_Key"" }")
rest.AddHeader("Content-Type", "application/json")
rest.AddHeader("Accept", "application/json")
Dim sbRequestBody As New Chilkat.StringBuilder
json.EmitSb(sbRequestBody)
Dim sbResponseBody As New Chilkat.StringBuilder
success = rest.FullRequestSb("POST", "/restapi/v2.1/accounts/xxxxxx/envelopes", sbRequestBody, sbResponseBody)
Dim respStatusCode As Integer = rest.ResponseStatusCode
我在这里粘贴代码供您参考,在该电子邮件、密码、密钥中我更改的所有内容,因为出于安全目的,它已重新发布。 当我传递带有值的模板角色时,我在代码上方得到 error.For 我从 api.
得到以下错误 return"errorCode":"INVALID_REQUEST_PARAMETER","message":"The request contained at least one invalid parameter. 'recipientId' not set for recipient."
请帮我解决这个错误。
此致, 亚拉文
尝试从第 8 行的 JSON 中删除 recipientId: 1
。
但我强烈建议您重新考虑您的架构选择。 您正在使用不太安全的旧版身份验证。
您可以使用 C# SDK,它是一个 Nuget 包,与 VB.NET 一起工作得很好,这将帮助您在不使用 JSON 和使用现代 OAuth 的情况下进行这些调用更安全。
这是使用 SDK 的代码:
Imports System
Imports System.Collections.Generic
Imports DocuSign.eSign.Api
Imports DocuSign.eSign.Client
Imports DocuSign.eSign.Model
Imports Microsoft.AspNetCore.Mvc
Private Function DoWork(ByVal signerEmail As String, ByVal signerName As String, ByVal ccEmail As String, ByVal ccName As String, ByVal accessToken As String, ByVal basePath As String, ByVal accountId As String, ByVal templateId As String) As String
Dim config = New Configuration(New ApiClient(basePath))
config.AddDefaultHeader("Authorization", "Bearer " & accessToken)
Dim envelopesApi As EnvelopesApi = New EnvelopesApi(config)
Dim envelope As EnvelopeDefinition = MakeEnvelope(signerEmail, signerName, ccEmail, ccName, templateId)
Dim result As EnvelopeSummary = envelopesApi.CreateEnvelope(accountId, envelope)
Return result.EnvelopeId
End Function
Private Function MakeEnvelope(ByVal signerEmail As String, ByVal signerName As String) As EnvelopeDefinition
Dim buffer As Byte() = System.IO.File.ReadAllBytes(Config.docPdf)
Dim envelopeDefinition As EnvelopeDefinition = New EnvelopeDefinition()
envelopeDefinition.EmailSubject = "Please sign this document"
Dim doc1 As Document = New Document()
Dim doc1b64 As String = Convert.ToBase64String(buffer)
doc1.DocumentBase64 = doc1b64
doc1.Name = "Lorem Ipsum"
doc1.FileExtension = "pdf"
doc1.DocumentId = "3"
envelopeDefinition.Documents = New List(Of Document) From {
doc1
}
Dim signer1 As Signer = New Signer With {
.Email = signerEmail,
.Name = signerName,
.ClientUserId = signerClientId,
.RecipientId = "1"
}
Dim signHere1 As SignHere = New SignHere With {
.AnchorString = "/sn1/",
.AnchorUnits = "pixels",
.AnchorXOffset = "10",
.AnchorYOffset = "20"
}
Dim signer1Tabs As Tabs = New Tabs With {
.SignHereTabs = New List(Of SignHere) From {
signHere1
}
}
signer1.Tabs = signer1Tabs
Dim recipients As Recipients = New Recipients With {
.Signers = New List(Of Signer) From {
signer1
}
}
envelopeDefinition.Recipients = recipients
envelopeDefinition.Status = "sent"
Return envelopeDefinition
End Function