RestClient Class
As its name implies, the RestClient
class is an Android app’s liaison to the Salesforce REST API.
You don’t explicitly create new instances of the RestClient
class. Instead, you use the ClientManager
factory class to obtain a RestClient
instance. Once you get the RestClient
instance, you can use it to send REST API calls to Salesforce. The method you call depends on whether you’re calling from a UI context. See ClientManager Class.
Use the following RestClient
methods to send REST requests:
sendAsync()
—Call this method if you obtained yourRestClient
instance by callingClientManager.getRestClient()
.sendSync()
—Call this method if you obtained yourRestClient
instance by callingClientManager.peekRestClient()
.
You can choose from three overloads of RestClient.sendSync()
, depending on the degree of information you can provide for the request.
The RestClient.sendAsync()
method wraps your RestRequest
object in a new instance of the OkHttpClient
Call
class. It then adds the Call
object to the request queue and returns that object.
Tocancel a request while it’s pending, call cancel()
on the Call
object. To access the underlying request queue object, use the OkHttpClient
class. See examples at Managing the Request Queue.