RestRequest Class

The RestRequest class natively handles the standard Salesforce data operations offered by the Salesforce REST API and SOAP API. It creates and formats REST API requests from the data your app provides. It is implemented by Mobile SDK and serves as a factory for specialized instances of itself.

Supported operations are:

Operation or ResourceParametersDescription
User Info  
SOQL QueryQuery string, API version, batch sizeReturns the requested fields of records that satisfy the SOQL query. By default, returns up to 2,000 records at once. If you specify a batch size, returns records in batches up to that size. Specifying a batch size does not guarantee that the returned batch is the requested size.
VersionsNoneReturns Salesforce version metadata
Object Layout  
Batch requestAPI version, flag telling the batch process whether to halt in the case of error, list of subrequestsReturns a RestRequest object containing a batch of up to 25 subrequests specified in a list of RestRequest objects. Each subrequest counts against rate limits.
ResourcesAPI versionReturns available resources for the specified API version, including resource name and URI
MetadataAPI version, object typeReturns the object’s complete metadata collection
DescribeGlobalAPI versionReturns a list of all available objects in your org and their metadata
DescribeAPI version, object typeReturns a description of a single object type
CreateAPI version, object type, map of field names to value objectsCreates a new record in the specified object
CompositeRequestAPI version, “all or none” flag that indicates whether to treat all requests as a transactional block in error conditions, hash map of subrequests (values) and their reference ID (keys)Returns a RestRequest object that you use to execute the composite request. Regardless of the number of subrequests, each composite request counts as one API call. See “Composite” in the REST API Developer Guide.
RetrieveAPI version, object type, object ID, list of fieldsRetrieves a record by object ID
SearchAPI version, SOQL query stringExecutes the specified SOQL search
SearchResultLayoutAPI version, list of objectsReturns search result layout information for the specified objects
SearchScopeAndOrderAPI versionReturns an ordered list of objects in the default global search scope of a logged-in user
SObject TreeAPI version, object type, list of SObject tree nodesReturns a RestRequest object for an SObject tree based on the given list of SObject tree nodes.
UpdateAPI version, object type, object ID, map of field names to value objects, If-Unmodified-Since date (optional)Updates an object with the given map. For conditional updates, Mobile SDK supports If-Unmodified-Since requests.
UpsertAPI version, object type, external ID field, external ID, map of field names to value objectsUpdates or inserts an object from external data, based on whether the external ID currently exists in the external ID field. If you set the name of the external ID field to“Id” and the external ID to null, a new record is created.
DeleteAPI version, object type, object IDDeletes the object of the given type with the given ID
NotificationAPI version, notification IDRetrieves the notification with the given ID.
NotificationUpdateAPI version, notification ID, read status, seen statusUpdates the “read” (if non-null) and “seen” (if non-null) statuses of the notification with the given ID.
NotificationsAPI version, number of notifications, date before, date afterRetrieves notifications sent before or after a given date. “Date before” and “date after” are mutually exclusive parameters.
NotificationsStatusAPI versionRetrieves the status of the current user’s notifications.
NotificationsUpdateAPI version, notification IDs, date before, read status, seen statusUpdates the “read” (if non-null) and “seen” (if non-null) statuses of notifications with the given IDs, or those sent before the given date. IDs and “date before” are mutually exclusive parameters.

To create instances of RestRequest, use one of the following RestRequest static factory methods.

  • getRequestForUserInfo()
  • getRequestForVersions()
  • getRequestForResources()
  • getRequestForDescribeGlobal()
  • getRequestForMetadata()
  • getRequestForDescribe()
  • getRequestForCreate()
  • getRequestForRetrieve()
  • getRequestForUpdate()
  • getRequestForUpsert()
  • getRequestForDelete()
  • getRequestForQuery()
  • getRequestForSearch()
  • getRequestForSearchScopeAndOrder()
  • getRequestForSearchResultLayout()
  • getRequestForObjectLayout()
  • getBatchRequest()
  • getCompositeRequest()
  • getRequestForSObjectTree()
  • getRequestForNotification()
  • getRequestForNotificationUpdate()
  • getRequestForNotifications()
  • getRequestForNotificationsStatus()
  • getRequestForNotificationsUpdate()

Each of these methods returns a RestRequest object. You send your request by passing the returned RestRequest object to RestClient.sendAsync() or RestClient.sendSync(). See Using REST APIs.

For sample calls, see /libs/test/SalesforceSDKTest/src/com/salesforce/androidsdk/rest/RestRequestTest.java at github.com/forcedotcom/SalesforceMobileSDK-Android.