Newer Version Available

This content describes an older version of this product. View Latest

Walkthrough for Query Jobs

This walkthrough shows you how to create a query job, monitor its progress, and get the job results.

This walkthrough uses Workbench to issue Bulk API 2.0 calls, but you can use any tool or development environment that can make REST requests.

  1. Create the job.
    1. In Workbench, log in to your org.
    2. Go to Utilities | REST Explorer. Create a query job by issuing a POST request with the following details:

      URI:

      1/services/data/vXX.X/jobs/query
      Request Body:
      1{
      2  "operation": "query",
      3  "query": "SELECT Id, Name FROM Account"
      4}

      The response includes the job ID and shows the job’s state to be UploadComplete. (You will use the job ID to monitor the job or get its results.)

      Submitting the job
  2. To monitor the state of the job, create a GET request. jobId is the job ID that was returned by the POST request that created the query job.
    1/services/data/vXX.X/jobs/query/jobId

    The response shows the current state of the job.

    getting the status of the job

    Repeat this step until the state is JobComplete.

  3. To get the results of the job, create a GET request with the following details:
    URI:
    1/services/data/vXX.X/jobs/query/jobId/results

    The response shows the results of the SOQL query run when you created the query job.

    the SOQL query results