docusign-esign-csharp-client icon indicating copy to clipboard operation
docusign-esign-csharp-client copied to clipboard

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

Open jaypman opened this issue 2 years ago • 3 comments

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<Document> { new Document { DocumentBase64 = documentBase64, Name = "TestDocument.pdf", FileExtension = "pdf", DocumentId = "1" } }, Recipients = new Recipients { Signers = new List<Signer> { new Signer { Email = signerEmail, Name = signerName, RecipientId = "1", Tabs = new Tabs { SignHereTabs = new List<SignHere> { 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:

Runtime Error
<body bgcolor="white">

        <span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1>

        <h2> <i>Runtime Error</i> </h2></span>

        <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">

        <b> Description: </b>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.
        <br><br>

        </font>

</body>

jaypman avatar Aug 08 '23 02:08 jaypman

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

troywdocusign avatar Aug 08 '23 05:08 troywdocusign

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?

jaypman avatar Aug 08 '23 13:08 jaypman

No problem at all, glad to help.

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

troywdocusign avatar Aug 08 '23 23:08 troywdocusign

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

garg-mudit avatar May 14 '24 07:05 garg-mudit

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.

garg-mudit avatar May 30 '24 18:05 garg-mudit