Newer Version Available
REST Resource Examples
Example Setup
The following examples use Apex to execute REST requests, but you can use any standard REST tool to access the Tooling API.
First, set up the connection to your org and the HTTP request
type:
At the end of each request, add the following code to send the request and retrieve the
body of the
response:
Retrieve a Description
To get a description of all available objects in Tooling API:
To get a description of a specific Tooling API object, for example, TraceFlag:
To get a description of all metadata for a specific Tooling API object, for example, TraceFlag:
Manipulate Objects by ID
To create a new Tooling API object, for example, MetadataContainer:
To retrieve a Tooling API object by ID, for example, MetadataContainer:
To update a Tooling API object by ID, for example, MetadataContainer:
To query a Tooling API object by ID, for example, MetadataContainer:
Query Within MetadataContainer
To query an object within a MetadataContainer:
Check Deployment Status
To check on the status of a deployment, using ContainerAsyncRequest:
Execute Anonymous Apex
To execute anonymous Apex:
Retrieve Apex
To retrieve your Apex classes and triggers, and the global Apex classes and triggers from your installed managed packages:
Execute Apex Unit Tests
To execute Apex unit tests, use the runTestsSynchronous or runTestsAsynchronous resource. This example illustrates how to POST to the runTestsSynchronous resource using JavaScript. The comment blocks show which objects these calls return.