2017-01-18 64 views
0

我正在嘗試一個簡單的示例來獲取在signedSign中籤名的pdf,但在嘗試使ViewUrl重定向用戶時遇到UNKNOWN_ENVELOPE_RECIPIENT錯誤。Docusign ViewUrl:UNKNOWN_ENVELOPE_RECIPIENT錯誤

這裏是我用來創建pdf文件的信封的代碼。

string recipientName = "Tester"; 
    string recipientEmail = "[email protected]"; 
    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 was unhandled by user code
ErrorCode=400 HResult=-2146233088 Message=Error calling CreateRecipientView: { "errorCode": "UNKNOWN_ENVELOPE_RECIPIENT",
"message": "The recipient you have identified is not a valid recipient of the specified envelope." }

+0

您是否在創建此信封時實際定義了收件人的clientUserID?名稱,email @和clientUserID三元組必須與創建信封時提供的收件人信息相匹配,以便成功創建收件人視圖。 –

+0

@LuisScott:謝謝,我不得不添加signer.ClientUserId =「1000」。您應該將您的評論轉換爲答案 – webber

回答

2

正如路易表示上述評論,您必須指定clientUserId財產在簽名者創建信封請求時,如果你希望能夠以隨後檢索該收件人的「查看」URL:

signer.clientUserId = 1000; 

您可以et clientUserId屬性爲您選擇的任何值 - 我在此示例中使用了,因爲這是您的代碼在帖子收件人視圖請求中使用的值。

ClientUserId = "1000", // must match clientUserId set in step #2! 

(該clientUserId,並您在郵報收件人查看指定要求必須完全匹配您在創建信封收件人指定的值電子郵件屬性值請求。)

相關問題