Search code examples
c#docusignapidocusign-sdk

DocuSign C# SDK No API Response


Trying to setup a ASP.NET Core web application with DocuSign SDK using JWT Authorization. When trying to call any Envelope API it never returns data and gets hung up.

var _apiClient = new DocuSignClient("https://demo.docusign.net/restapi");

var privateKeyBytes = GetPrivateKeyBytes();
var authToken = _apiClient.RequestJWTUserToken("integration_key", "user_id", "account-d.docusign.com", privateKeyBytes: privateKeyBytes, 1, new List<string> { "impersonation", "signature" });

// authToken object returns correctly with access_token, calling _apiClient.GetUserInfo(authToken.access_token) will return a valid object as well.

var envelopesAPI = new EnvelopesApi(_apiClient);
// never gets past this line, constantly loads.
Envelope env = envelopesAPI.GetEnvelope("api_account_id", "envelope_id");

I've checked my DocuSign API Dashboard and can see these requests are being completed (200) but still not receiving an object and unable to get past that line, no error is being thrown either I've tried letting it run for a bit to see if it would eventually throw one but I didn't seem to get one.

Successful request

I also get a successful JSON response if sending the request through postman using access_token generated by code.

Any help is appreciated, thanks.


Solution

  • To use JWT, you need to make sure that you have consent. The call to get an access token will fail if the information you pass to it is incorrect. For example, the "user_id" that you have in there must be a valid GUID of a user (not account!) in the system that corresponds to the account you used to log in when you gave consent.

    If you do get a valid access token, then you have to add this code:

    string access_token = authToken.access_token;
    apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);