docusign / docusign-esign-csharp-client

The Official Docusign C# Client Library used to interact with the eSignature REST API. Send, sign, and approve documents using this client.
https://developers.docusign.com/docs/esign-rest-api/sdks/csharp/
MIT License
129 stars 159 forks source link

CreateRecipientViewAsync is returning UNKNOWN_ENVELOPE_RECIPIENT when trying to create a second one #446

Open LSPsyko opened 1 month ago

LSPsyko commented 1 month ago

Hi, When trying to recreate an ViewUrl for an envelop, I got the "CreateRecipientViewAsync is returning UNKNOWN_ENVELOPE_RECIPIENT". It works for the first time but not a second opening

Thks, code below

 ```
   EnvelopesApi envelopesApi = CreateEnvelopApi();
        //var envelop = await envelopesApi.GetEnvelopeAsync(_account!.AccountId, existingEnveloppe.EnvelopeId);

        var recipients = await envelopesApi.ListRecipientsAsync(_account!.AccountId, existingEnveloppe.EnvelopeId);
        var signer = recipients.Signers.FirstOrDefault(x => x.Email == student.Email);
        var token = _configuration.GetOptions<DocusignOptions>().ApiKey;
        string returnUrl = $"{_configuration.GetOptions<DocusignOptions>().ReturnUrl}/dsreturn?studentId={studentId}&envelopId={existingEnveloppe.EnvelopeId}&token={token}";

        var viewRequest = new RecipientViewRequest
        {
            ReturnUrl = returnUrl,
            ClientUserId = signer.ClientUserId,
            UserId = signer.UserId,
            Email = signer.Email,
            AuthenticationMethod = "none",
            //RecipientId = signer.RecipientId,

        };
        ViewUrl? embedded = await envelopesApi.CreateRecipientViewAsync(_account.AccountId, existingEnveloppe.EnvelopeId, viewRequest);

        return embedded.Url;
esilva600 commented 1 month ago

Hello,

The error UNKNOWN_ENVELOPE_RECIPIENT happens when you try to use a different recipient from the ones that exist in the envelope.

Another cause is when someone changes the Recipient Name, for example, they insert or remove initials or use nicknames as their usernames.

For example, if you create a Recipient named Howard Philips and then it is updated to H. P. Lovecraft, it will cause the unknown_envelope_recipient Error.

To correct this you will need to delete the Envelope Recipient views, and then create a new Recipient View for this Envelope Recipient.

Below is the code sample to delete the Recipient View: https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/envelopeviews/deleteenvelopecorrectview/

If you need any more help, you can open a Support Ticket, mentioning the Envelope Recipients and the Envelope IDs you're experiencing this error.

LSPsyko commented 1 month ago

The recipient I'm setting is from the existing recipients of the envelope and no changes are applied.

Trying to delete the correctViews I got this error: "errorCode":"INVALID_REQUEST_BODY","message":"The request body is missing or improperly formatted."