Reading list Switch to dark mode

    How to Run REST API Through Workbench Salesforce?

    Updated 1 August 2023

    In this blog we will learn about how we can run REST API through Workbench to retrive, create, update or delete the data of our Salesforce org. Let us get started!

    Prerequisites

    1) Click on the link to open workbench: Workbench
    2) Log in to your Salesforce Org, and allow access.
    3) Go to Utilities > REST Explorer

    REST Explorer through Workbench

    When you open REST explorer, you will find the following by default:

    Workbench Salesforce

    1) HTTP method set to Get.

    Searching for an experienced
    Salesforce Company ?
    Find out More

    2) URI set to following:

    /services/data/v39.0

    3) When you click on Headers button you will find that Request Headers is set to following code by default:

    Content-Type: application/json; charset=UTF-8
    Accept: application/json

    Through the above header you can get JSON response. If you want to receive your response in XML format, set the below code in Request Headers

    Content-Type: application/json; charset=UTF-8
    Accept: application/xml

    Let us execute the default set URI. You’ll get the output as below:

    Workbench Salesforce

    Workbench Salesforce

    CRED operations using REST API

    Let us perform the CRED operations using REST API:

    >> CREATE:

    For creating records through REST API we use the /sobjects/ URI. Please make sure HTTP method is set to POST

    Step 1: Set the URI according to the object you want to insert.

    /services/data/v39.0/sobjects/Account

    Step 2: Set the Request Body with fields and its values

    {
        "Name":"Test Company"
    }

    Step 3: Execute.

    You will get the following result:

    Workbench Salesforce

    >> READ:

    We will perform READ operation through SOQL query using REST API. Please make sure that HTTP method is set to GET We have following resources for requesting SOQL query through REST API :

    1) /query : It returns all the records present in the org according to the query.

    /services/data/v39.0/query/?q=Select+Id,Name+from+Account+LIMIT+10

    2) /queryAll : It returns all the records present in the org, including the deleted records which are present in “recycle bin”, according to the query.

    /services/data/v39.0/queryAll/?q=Select+Id,Name+from+Account+LIMIT+10

    >> EDIT:

    For editing/updating records through REST API we use the /sobjects/ URI. Please make sure HTTP method is set to PATCH

    Step 1: Set the URI according to the object you want to edit, and also mention the related Id.

    /services/data/v39.0/sobjects/Account/0012800001HX02zAAD

    Step 2: Set the Request Body with fields and its values

    {
        "Name":"Test Company",
        "AccountNumber":"abc123"
    }

    Step 3: Execute.

    You will get the following result:

    Workbench Salesforce

    >> DELETE:

    For deleting records through REST API we use the /sobjects/ URI. Please make sure HTTP method is set to DELETE

    Step 1: Set the URI according to the object you want to delete, and also mention the related Id.

    /services/data/v39.0/sobjects/Account/0012800001HX02zAAD

    Step 2: Execute.

    You will get the following result:

    Workbench Salesforce

    Support

    That’s all for how to run REST API through Workbench, still have any issues feel free to reach us via email at [email protected] and let us know your views to make the code better.

    You can also Hire Salesforce Developers to help your business deliver more by providing expertise and resources for all kinds of Salesforce development projects.

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    Be the first to comment.

    Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home

    Table of Content