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

Getting 500 error code for SDK on API calls with no ErrorMessage details. #417

Closed jaypman closed 1 month ago

jaypman commented 11 months ago

I passed in a valid accessToken which I got from the Authorization Code Grant Flow. Called API. Getting this error with no detailed information on what the issue is. Am I missing something? I also checked the API Request Log section in the Account dashboard.. nothing..

var docuSignClient = new DocuSignClient("https://demo.docusign.net/restapi"); docuSignClient.Configuration.DefaultHeader.Add("Authorization", $"Bearer {accessToken}"); var envelopesApi = new EnvelopesApi(docuSignClient);

// Prepare the envelope definition var envelopeDefinition = new EnvelopeDefinition { EmailSubject = "Please sign this document", Documents = new List { new Document { DocumentBase64 = documentBase64, Name = "TestDocument.pdf", FileExtension = "pdf", DocumentId = "1" } }, Recipients = new Recipients { Signers = new List { new Signer { Email = signerEmail, Name = signerName, RecipientId = "1", Tabs = new Tabs { SignHereTabs = new List { new SignHere { DocumentId = "1", PageNumber = "1", RecipientId = "1", TabLabel = "SignHereTab", XPosition = "100", YPosition = "100" } } } } } }, Status = "sent" };

try { // Call the create envelope endpoint using the SDK method var results = await envelopesApi.CreateEnvelopeAsync(AccountId, envelopeDefinition); return results.EnvelopeId; }

catch (ApiException ex) { var errorCode = ex.ErrorCode; // returns 500 var errorMessage = ex.ErrorMessage; // returns ""

}

ex.Message returns this:

Error calling CreateEnvelope: <!DOCTYPE html>

Runtime Error

Server Error in '/' Application.

Runtime Error

Description: An exception occurred while processing your request. Additionally, another exception occurred while executing the custom error page for the first exception. The request has been terminated.

troywdocusign commented 11 months ago

Hi,

If there are no logs in the API Logs dashboard then I doubt your code is working & reaching the DocuSign API. You could look at ex.InnerException to try to find the detail.

Otherwise I suggest you checkout https://apirequestbuilder.docusign.com/ which connects directly to your developer account & generates code, I have done this and it works perfectly with my generated code.

Here is your code snippet which worked for me on my developer account with some minor changes.

https://gist.github.com/troywdocusign/8210ea585bb907d71badb6686d8db307

jaypman commented 11 months ago

Thanks! I tried the API request builder. Very useful tool! It works now..

Looks like I was using DocuSignClient but instead should of been using ApiClient

Do you know what is the difference?

troywdocusign commented 11 months ago

No problem at all, glad to help.

You should be using the DocuSignClient has the ApiClient has been marked as Obsolete

garg-mudit commented 2 months ago

Hi @jaypman , Were you able to get it working via DocuSignClient ?

garg-mudit commented 1 month ago

Closing this issue due to no further response from customer. Please feel free to reopen this issue or create a new one in case you feel the need.

Thank You.