Skip to navigation

How to make a direct API call

View as Markdown

This topic demonstrates how you can make a direct API call to the eSignature REST API from the Docusign Android SDK module if there is no existing SDK method; in this case, to retrieve a user’s signature ID.

Required data

Running the code in this how-to requires this data:

Data elementDescription
{API_ACCOUNT_ID}A GUID value that identifies your account. This value is automatically generated by Docusign for any account you create. Copy the value from the API Account ID field on the Apps and Keys page.
{IMPERSONATION_USER_GUID}A GUID value that identifies the user. This value is automatically generated by Docusign. Copy the value from the User ID field on the Apps and Keys page.

Step 1. Log in to Docusign

To make the API calls shown in this how-to, you must be logged in to Docusign.

See How to log in to Docusign from your app for details.

Step 2. Construct your API headers

Use the getESignAPIDelegate method to retrieve the API account ID and user ID needed to get the user signature ID.

DSESignApiDelegate eSignApiDelegate = DocuSign.getInstance().getESignApiDelegate();
final UsersApi usersApi = eSignApiDelegate.createApiService(UsersApi.class);
if (usersApi != null) {
DSAuthenticationDelegate authDelegate = DocuSign.getInstance().getAuthenticationDelegate();
final DSUser user = authDelegate.getLoggedInUser(getApplicationContext());

Step 3. Call the eSignature REST API to get the user signature ID

Next, use the account information you retrieved in step 2 to make the direct API call via the userSignaturesGetUserSignatures method.

eSignApiDelegate.invoke(new DSESignApiListener() {
@Override
public <T> void onSuccess(T response) {
if (response instanceof UserSignaturesInformation) {
UserSignature userSignature = ((UserSignaturesInformation) response).getUserSignatures().get(0);
Log.d("makeDirectApiCall", "Signature Id: " + userSignature.getSignatureId());
}
}
}, () -> usersApi.userSignaturesGetUserSignatures(user.getAccountId(), user.getUserId(), "signature"));

Expected response

You should receive your user’s signature ID.

Signature Id: 7faf2365-xxxx-xxxx-xxxx-1cbd9e6dff30

Next steps