Tool Used: Workbench (https://workbench.developerforce.com/login.php?startUrl=%2FrestExplorer.php).
Tool Description: Workbench is a suite of tools that facilitates interactions with Salesforce org through the Application programming interface (API). There are plenty of tools available for you to use when it comes to making REST requests from any HTTP sender (for example, check out cURL or Postman). However, Workbench provides a friendly framework specifically for Salesforce APIs and therefore it is the perfect way to dig in before you’re ready to write a full-on integration.
Steps for working with Workbench: Following are the points to make API request via Workbench:
- Go to the link: https://workbench.developerforce.com/login.php?startUrl=%2FrestExplorer.php
- Select the desired environment and API version and then proceed to select the agreement.
- Log in with your Salesforce credentials.
- The text in the text box represents a resource Uniform Resource Identifier (URI, only a part of it gets displayed). The radio buttons above the URI represent the standard HTTP methods. To make an API call, we will have to enter the resource URI, select the appropriate method, add headers as needed, and then click on Execute.
Example: Using the GET method to fetch metadata about an object and its fields.
- Paste this URI in box: /services/data/v46.0/sobjects/account/describe:
- /services/data—Specifies that we’re making a REST API request
- /v46.0—API version number
- /sobjects—Specifies that we’re accessing a resource under the sObject grouping
- /account—sObject being actioned; in this case, account
- /describe—Action; in this case, a describe request
- Now make sure that the GET method is selected, and click Execute.
3. The Account metadata appears on the screen (in a formatted form). Click Show Raw Response.
- To view response in XML: replace application/json with application/xml in header.
- One can use other HTTP method to achieve different goals.
- For example, use POST method to create a record of any object type.