Need Docusign API Endpoint

2019-07-25 03:35发布

The docs https://docs.docusign.com/esign/guide/authentication/legacy_auth.html do not work. I've spent at least 2 hours trying to get these instructions to work. Either your instructions are wrong, or they have a bug on their site.

I opened a case with support 4 days ago, but they have not responded. I am on a time crunch to get this going. Does anyone know how to get this url.

Here is my C# code:

    ApiClient apiClient = new ApiClient("https://www.docusign.net/restapi");
    DocuSign.eSign.Client.Configuration.Default.ApiClient = apiClient;
    DocuSignHeader myHeader = new DocuSignHeader()
    {
    Username = ConfigurationManager.AppSettings["DocuSignUsername"],
    Password = ConfigurationManager.AppSettings["DocuSignPassword"],
    IntegratorKey = ConfigurationManager.AppSettings["DocuSignIntegratorKey"],
    };
    DocuSign.eSign.Client.Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", JsonConvert.SerializeObject(myHeader));
    AuthenticationApi authApi = new AuthenticationApi();
    LoginInformation loginInfo = authApi.Login();
    LoginAccount myAccount = loginInfo.LoginAccounts[0];
.. create envelope here..
   EnvelopesApi envelopesApi = new EnvelopesApi(GetBasePath(myAccount.BaseUrl));
   EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(myAccount.AccountId, envDef);

The purpose of GetBasePath() is to strip off everything after 'restapi', so the url is correct.

标签: docusignapi
1条回答
该账号已被封号
2楼-- · 2019-07-25 04:08

The DocuSign live production system has multiple account sub-domains as opposed to the demo system which only uses demo. For instance, in production the possible sites are www, na2, na3, eu.

Your integration code needs to parse the sub-domain of the baseUrl that is returned from your authentication request and re-configure the apiClient with that new sub-domain.

It looks like you are using a DocuSign SDK, there's a note in the readme that explains this:


Authentication

Service Integrations that use Legacy Header Authentication

(Legacy Header Authentication uses the X-DocuSign-Authentication header.)

Use the Authentication: login method to retrieve the account number and the baseUrl for the account. The url for the login method is www.docusign.net for production and demo.docusign.net for the developer sandbox. The baseUrl field is part of the loginAccount object. See the docs and the loginAccount object

The baseUrl for the selected account, in production, will start with na1, na2, na3, eu1, or something else. Use the baseUrl that is returned to create the basePath (see the next step.) Use the basePath for all of your subsequent API calls.

As returned by login method, the baseUrl includes the API version and account id. Split the string to obtain the basePath, just the server name and api name. Eg, you will receive https://na1.docusign.net/restapi/v2/accounts/123123123. You want just https://na1.docusign.net/restapi Instantiate the SDK using the basePath. Eg ApiClient apiClient = new ApiClient(basePath);

Set the authentication header as shown in the examples by using Configuration.Default.AddDefaultHeader

Reference: C# SDK


Code Sample

Here is the corresponding C# code to do exactly what is mentioned above (ie strip the sub-domain of the baseUrl and re-configure the apiClient):

// Update ApiClient with the new base url from login call
string[] separatingStrings = { "/v2" };
apiClient = new ApiClient(loginInfo.LoginAccounts[0].BaseUrl.Split(separatingStrings, StringSplitOptions.RemoveEmptyEntries)[0]);
查看更多
登录 后发表回答