Comments (5)
@Ergin008 not sure why this is closed ?
All the REST API guide docs say that you need to obtain the login information to get the baseUrl and use that on subsequent API calls. If you don't use the right server URL (e.g. NS1/NS2/EU etc..) your calls may not go through.
I understand the base path is either http://demo.docusign.net/restapi (sandbox) or http://www.docusign.net/restapi (prod) when getting the login information initially via the API client.
But if the SAME API client instance is THEN used with the EnvelopesApi to create an envelope without changing the base path to correspond to the baseURL in the login info, it may not work as you aren't hitting the right server for the envelopes call.
From what i can see the APIClient does not magically adjust its base path to point to the correct server NS1/NS2 etc.. after the login information is obtained, this has to be done manually. And the only way to do this is with the setBasePath() method on the API client, which won't actually work unless you do some substring manipulation first as there is some duplication in portions of the path returned from the login account info and that constructed by the envelopes api. Example:
apiClient.addDefaultHeader("X-DocuSign-Authentication", "....");
// get login info
AuthenticationApi authenticationApi = new AuthenticationApi(apiClient);
LoginAccount loginAccount = authenticationApi.login().getLoginAccounts().get(0);
String loginBaseURL = loginAccount.getBaseUrl();
// example: say base URL returned is https://eu.docusign.net/restapi/v2/accounts/xyz
// create envelope
EnvelopesApi envelopesApi = new EnvelopesApi(apiClient);
envelopesApi.createEnvelope(loginAccount.getAccountId(), envelope);
The call to create the envelope will still hit the server https://www.docusign.net/ and NOT https://eu.docusign.net, so you have to change it in the api client.
apiClient.addDefaultHeader("X-DocuSign-Authentication", "....");
// get login info
AuthenticationApi authenticationApi = new AuthenticationApi(apiClient);
LoginAccount loginAccount = authenticationApi.login().getLoginAccounts().get(0);
String loginBaseURL = loginAccount.getBaseUrl();
// example: say base URL returned is https://eu.docusign.net/restapi/v2/accounts/xyz
// update the client url
apiClient.setBasePath(loginBaseURL.substring(0,loginBaseURL.indexOf('v2/')+ 3 ... etc)
// create envelope
EnvelopesApi envelopesApi = new EnvelopesApi(apiClient);
envelopesApi.createEnvelope(loginAccount.getAccountId(), envelope);
Now the envelope call will hit the EU server and not www.docusign.net.
Am i missing something ? If not, Is this going to be resolved or should this munging of the path be the acceptable solution ?
from docusign-esign-java-client.
Hi @ctmckenna, are you testing all of this with a production account or are you using a developer sandbox account created through the dev center?
In any case I think some of the confusion is due to terminology here - when instantiating the api client you actually set the basePath
of the REST API you're using, not the baseUrl
returned from the login call for a given user. That information (such as the actual baseUrl your account/user resides on) is actually encapsulated from you as a caller of this java client - all you have to do is tell the client what environment you're using and it should take care of the underlying URL paths, etc.
For instance, if you are testing with a developer sandbox account (which operates in the demo environment) you would do:
apiClient.setBasePath("https://demo.docusign.net/restapi");
Otherwise, if you've purchased an account and are live in production then you would do
apiClient.setBasePath("https://www.docusign.net/restapi");
Please give that a try (based on what environment you're using) and let us know if that doesn't work.
Cheers,
-Ergin
from docusign-esign-java-client.
Thanks @Ergin008, do you mind pointing me to the code that encapsulates the actual baseUrl my account resides on? From what I can see, nothing changes ApiClient's basePath internally.
For some reason I get a USER_AUTHENTICATION_FAILED error from the following code in the production environment (but it works in the developer sandbox using the sanbox base path).
apiClient.setBasePath("https://www.docusign.net/restapi");
apiClient.addDefaultHeader("X-DocuSign-Authentication", "{\"Username\":\"" + email + "\",\"Password\":\"" + password + "\",\"IntegratorKey\":\"" + integratorKey + "\"}");
Configuration.setDefaultApiClient(apiClient);
try {
AuthenticationApi authenticationApi = new AuthenticationApi();
String accountId = authenticationApi.login().getLoginAccounts().get(0).getAccountId();
EnvelopesApi envelopesApi = new EnvelopesApi();
return envelopesApi.getDocument(accountid, envelopeId, "combined");
} catch (Exception e) {}
The getDocument api call works when I manually parse out the hostname from the LoginAccount:
apiClient.setBasePath("https://na2.docusign.net/restapi");
from docusign-esign-java-client.
@ctmckenna The basePath does not actually change once you set it, what I mean is client creates the appropriate URL needed for a given API call by appending the basePath to the URI for a given call. You do not have to explicitly do that yourself, the client takes care of it for you.
If you're saying the code works in Demo but does not work in production then - based on the error message you're getting - I would guess you don't have a valid production account? Have you purchased an API Plan for instance or are you testing with a free trial account or something of that nature? If you purchased an API Plan then you'll need to pass Certification before you can use that production account with the API.
More info here: https://secure.docusign.com/developer
from docusign-esign-java-client.
@Ergin008 It says here that we need to change the base url to the one returned from "/login_information": https://www.docusign.com/p/RESTAPIGuide/RESTAPIGuide.htm#GettingStarted/REST API Base URL.htm%3FTocPath%3DGetting%2520Started%7C_____5
The link seems to be correct because when I dont use that baseUrl, I get a USER_AUTHENTICATION_FAILED error.
You said earlier that "the actual baseUrl your account/user resides on is actually encapsulated from you as a caller of this java client", and I asked where this happens in the code because I'm not seeing it. When I call login() in AuthenticationApi.java on production, the baseUrl returned is "https://na2.docusign.net/restapi". Only when I manually update ApiClient.java's baseUrl to this new value am I able to use the production API. I'm commenting here because I agree that this should be encapsulated within ApiClient.java, and it looks like the code expects it to work that way, especially since there's no mention of the returned baseUrl in CoreRecipes.java. Would you mind pointing me to the place where this is supposed to happen?
It seems like others have had to do this as well. Here's a client library that does use the baseUrl returned from /login_information: https://github.com/Ergin008/eSignJavaLib/blob/master/src/com/docusign/esignature/DocuSignClient.java
from docusign-esign-java-client.
Related Issues (20)
- "errorCode":"REQUIRED_TAB_INCOMPLETE" HOT 4
- How to send the same envelope for two group of people? HOT 1
- How to Use both embedded signing and email with the same envelopeId? HOT 2
- How to publish multiple templates from the development environment to the production environment? HOT 1
- 《EnvelopeDocuments : get 》 The obtained pdf file has no tabs HOT 1
- Not a good practice to manipulate System level property and only allow TLS 1.2 HOT 4
- Classloader leak due to ApiClient$SecureTrustManager HOT 1
- SDK is not typesafe HOT 2
- Can I use an older docusign version (3.14) with older java version (8)? HOT 1
- Dependency version issues when updating from v3.19.0 to 3.22.0 HOT 6
- Transitive dependencies are gone in version 4.1.0 HOT 7
- DocuSign API to fech AuditLogs Information HOT 4
- Filename for pdfs in zip archive do not match EnvelopeDocument.getName() HOT 4
- Dependency conflict: jakarta/ws/rs/ext/ContextResolver HOT 2
- How to open Agreement Cloud Editor in our own website
- How to open Agreement Cloud Editor in our own website HOT 2
- [Question] Sending MS Word Docx file with ContentControls used to work, now it displays the content control in DocuSign HOT 2
- jersey-common missing from external dependency in readme HOT 2
- Model classes should be serializable HOT 6
- Docusign Focused is rendering an invisible iframe which makes complete app unusable HOT 20
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docusign-esign-java-client.