0

I'm trying out a simple example to get a pdf signed in docuSign, but I'm running into the UNKNOWN_ENVELOPE_RECIPIENT error when trying to get the ViewUrl to redirect the user.

Here is the code I'm using to to create the envelope with the pdf doc.

    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!

Complete error:

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." }

2
  • 1
    Did you actually define the clientUserID of the recipient when creating this envelope? The triplet of name, email@, and clientUserID must match the recipient information provided during envelope creation in order to successfully create a recipient view.
    – Luis
    Commented Jan 18, 2017 at 14:29
  • @LuisScott: thanks, i had to add signer.ClientUserId = "1000". You should convert your comment to an answer
    – webber
    Commented Jan 18, 2017 at 15:31

1 Answer 1

5

As Luis indicates in the comment above, you must specify the clientUserId property for the signer in the Create Envelope request, if you want to be able to subsequently retrieve the "View" URL for that Recipient:

signer.clientUserId = 1000;

You can set the clientUserId property to any value you choose -- I used 1000 in this example because that's the value that your code is using in the Post Recipient View request.

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

(The clientUserId, name, and email property values that you specify in the Post Recipient View request must exactly match the values that you specified for the Recipient in the Create Envelope request.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.