Clover Platform Docs

Querying web services

To see our APIs in action, visit the Clover Android SDK examples directory in the Clover Android SDK. The examples use the Clover APIs to connect to Services, query Clover ContentProviders, and fetch data directly from the Clover REST API.

Querying a Web Service

WebServiceActivity shows how the Clover REST API can be queried directly once the Clover Account and authToken are retrieved.

  1. Get a merchant's CloverAccount:
private Account mAccount;
protected void onCreate(Bundle savedInstanceState) {
  mAccount = CloverAccount.getAccount(this);
  1. Get your app's authToken using the CloverAuth.authenticate call in a background thread:
CloverAuth.AuthResult authResult = CloverAuth.authenticate(WebServiceActivity.this, mAccount);
  1. If successful, the AuthResult will contain the authToken and baseUrl. Query the REST API to get merchant information using the included CustomHttpClient:
CustomHttpClient httpClient = CustomHttpClient.getHttpClient();

// First we get the base URL, merchant ID, and API token
String baseUrl = authResult.authData.getString(CloverAccount.KEY_BASE_URL);
String merchantId = authResult.merchantId;
final String apiToken = authResult.authToken;

// Now we get merchant information using the merchant ID
String merchantUri = "/v3/merchants/" + merchantId;
url = authResult.baseUrl + merchantUri + "?access_token=" + authResult.authToken;
result = httpClient.get(url);

You can find more examples in Clover's Android Examples Repository on GitHub.



There are important changes to the Android SDK auth token generation.

Updated 6 months ago

Querying web services

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.