Read More
Read More
Menu Close

    How to run REST API through Workbench Salesforce

    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:

    1) HTTP method set to Get.

    Searching for an experienced
    Salesforce Company ?
    Read 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:

    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:

    >> 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:

    >> 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:

    Support

    That’s all for how to run REST API through Workbench, still have any issue feel free to add a ticket and let us know your views to make the code better https://webkul.uvdesk.com/en/customer/create-ticket/

     

    . . .
    Discuss on Helpdesk

    Leave a Comment

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


    Be the first to comment.

    Back to Top

    Table of Content