Sales: | +91-917-317-5751
HR: | +91-962-477-169

Salesforce - REST API and Queries With workbench

Jul 09, 2018 Asp.Net,API Integration 0 3062

Salesforce - REST API and Queries With workbench

This article helps you to understand

  • How to use Workbench environment in Salesforce for getting URL in REST API call
  • REST Explorer panel of salesforce workbench
  • REST API call for fetching any data
  • Query understanding and pass queries with Salesforce REST API

Workbench environment in Salesforce:

Workbench is a collection of tools for interacting with your Salesforce through the API. Workbench provides a friendly environment especially for Salesforce APIs, it’s the perfect way to go deeply go inside and test your API's before you’re finalized your actual code integration.

Steps to log in to Workbench:

  • Navigate to Workbench.
  • With Environment, select Production.
  • With API Version, select latest version number.
  • Select I agree to the terms of service.
  • Click Login with Salesforce. These steps give you an entry point inside the workbench.

There are multiple features provided by workbench but here, in this article, we discuss only the REST API Explorer and SOQL query.

For REST API inside workbench:

Inside workbench, Navigate through utilities/REST Explorer/sobjects. This will allows you to access all the object data inside salesforce.

The text in the text box represents a resource URI. For easy to use, the top-level domain is omitted from the displayed URI in the workbench. For example, the full URI of the resource that’s prepopulated in the URI text box is Radio buttons above the URI represent the standard HTTP methods.

Let's take a tour of SObject Describe resource. This resource, when combined with the GET method, returns metadata about an object and its fields.

In sobjects, you may find a number of objects. For easy to understand let's continue with account object.

If you navigate through Sobjects/AccountURLss then you will be able to see all the builtin API URIs provided by Salesforce to make any REST API call.

As per your requirement you can pick any of them with and able to fetch data. For example, if you want to see the list of all accounts then use URL listview.

Let's broke the URI inside the textbox and try to understand then,

/services/data—Specifies that we’re making a REST API request

/v36.0—API version number

/sobjects—Specifies that we’re accessing a resource under the sObject grouping

/account—sObject being actioned; in this case, account

/listview—Action; in this case, a listview request

Thus, this is a way to test your API and plan for using APIs for salesforce object before actually implementing Salesforce REST API call inside your application.

For Database inside workbench:

Until now whatever we discuss is limited up to object level. Now, what is the option; if you want to combine two or more objects together and by joining them you want to fetch the data? In this case, you must have knowledge of the Salesforce database.

In this scenario, workbench provides SQL Explorer option to navigate through the Salesforce database. You can access the tables inside Salesforce using queries/SOQL query.

If you have good knowledge of objects inside salesforce, then you can combine two or more objects and prepare your final query using joins. Once you get the perfect result as per your expectation then you can make a use of that SQL final query within your REST API call.

To make a REST API call with query salesforce provides a fixed format of URI I.e

Here, vxx.x indicates the version number of your API.

So, this is a simplest and easiest way to test your salesforce REST API before actually using them inside your application.

Blog Author


Leave a Comment