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
130 stars 159 forks source link

SDK provides no access to the errorDetails object #314

Closed Major-Mike closed 3 months ago

Major-Mike commented 3 years ago

When using the SDK call: envelopesApi.ListStatusChanges(..) there is no access to the errorDetails object per API reference schema to check before returning or acting on the response.

Additionally being wrapped in the API object, there is no way I can see to check the status code for 200/400 either, so how do we handle error check then? What am I missing here?

MattKingDS commented 3 years ago

Hi Mike,

Sorry to hear you ran into this issue. What you're describing is a bug in our SDK where the response headers are not being properly handled on their way back from DocuSign. The internal reference code for the ticket is DCM-4714.

The good news is that if you're looking for error codes you can still get to the error codes. Running the C# SDK version 5.2 in Visual Studio Professional 2019, I was able to retrieve them using a try/catch with an APIException.

try
            {
               EnvelopeSummary response = envClient.CreateEnvelope(AccountId, envDef);
                Console.WriteLine("Response : " + response.EnvelopeId);
            }
            catch (ApiException e)
            {

                Console.Write("Exception : " + e.ErrorCode + Environment.NewLine + "Error Message: " + e.Message);
            }

            Console.ReadLine();

Output: Exception : 401 Error Message: Error calling CreateEnvelope: {"errorCode":"USER_AUTHENTICATION_FAILED","message":"One or both of Username and Password are invalid."}

Regards, Matt DocuSign Developer Support

Major-Mike commented 3 years ago

@MattKingDS Ok, understood. Hopefully they will add that in the future. In the meantime yes I was aware of the crash and catch, which is what I resorted to in the meantime. Glad we are on the same page on that part, saves me asking for thoughts on a workaround 😃 Thanks.