我正在尝试一个简单的示例来获取在docuSign中签名的pdf,但是在尝试让ViewUrl重定向用户时,我遇到了UNKNOWN_ENVELOPE_RECIPIENT错误。
以下是我用来创建pdf文档信封的代码。
string recipientName = "Tester";
string recipientEmail = "test@me.com";
string accountId = AuthenticateDocuSign();
byte[] fileBytes = File.ReadAllBytes(@"C:\temp\test.pdf");
EnvelopeDefinition envDef = new EnvelopeDefinition();
envDef.EmailSubject = "[DocuSign C# SDK] - Please sign this doc";
// Add a document to the envelope
DocuSign.eSign.Model.Document doc = new DocuSign.eSign.Model.Document();
doc.DocumentBase64 = System.Convert.ToBase64String(fileBytes);
doc.Name = "TestFile.pdf";
doc.DocumentId = "1";
envDef.Documents = new List<DocuSign.eSign.Model.Document>();
envDef.Documents.Add(doc);
// Add a recipient to sign the documeent
Signer signer = new Signer();
signer.Email = recipientEmail;
signer.Name = recipientName;
signer.RecipientId = "1";
// Create a |SignHere| tab somewhere on the document for the recipient to sign
signer.Tabs = new Tabs();
signer.Tabs.SignHereTabs = new List<SignHere>();
SignHere signHere = new SignHere();
signHere.DocumentId = "1";
signHere.PageNumber = "1";
signHere.RecipientId = "1";
signHere.XPosition = "100";
signHere.YPosition = "100";
signer.Tabs.SignHereTabs.Add(signHere);
envDef.Recipients = new Recipients();
envDef.Recipients.Signers = new List<Signer>();
envDef.Recipients.Signers.Add(signer);
// set envelope status to "sent" to immediately send the signature request
envDef.Status = "sent";
// |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests)
EnvelopesApi envelopesApi = new EnvelopesApi();
EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);
RecipientViewRequest viewOptions = new RecipientViewRequest()
{
ReturnUrl = returnURL,
ClientUserId = "1000", // must match clientUserId set in step #2!
AuthenticationMethod = "email",
UserName = recipientName,
Email = recipientEmail,
};
ViewUrl recipientView = envelopesApi.CreateRecipientView(accountId, envelopeSummary.EnvelopeId, viewOptions); // EXCEPTION!
完成错误:
DocuSign.eSign.Client.ApiException未被用户代码
处理 ErrorCode = 400 HResult = -2146233088消息=调用错误 CreateRecipientView:{“errorCode”:“UNKNOWN_ENVELOPE_RECIPIENT”,
“message”:“您识别的收件人不是有效的收件人 指定的信封。“}
答案 0 :(得分:3)
正如Luis在上面的评论中指出的那样,您必须在创建信封请求中为签名者指定 clientUserId 属性,如果您希望以后能够检索该“收件人”的“查看”网址:
signer.clientUserId = 1000;
您可以将 clientUserId 属性设置为您选择的任何值 - 我在此示例中使用了 1000 ,因为这是您的代码在中使用的值发布收件人视图请求。
ClientUserId = "1000", // must match clientUserId set in step #2!
(您在发布收件人视图请求中指定的 clientUserId ,名称和电子邮件属性值必须与您在创建信封请求中为收件人指定的值完全匹配。)