How to use Apex Rest API’s in Salesforce using Postman

Being a Developer it’s always a plus point having knowledge of implementing Web services and integrating multiple platforms with Salesforce. I am an integration nerd and I love to explore new possibilities. I very often come across questions about “Testing the REST API’s” so I cannot resist sharing some great amount of knowledge for all new developers with this blog “How to use Apex Rest API’s in Salesforce using Postman”.

In this blog, I’ll explain a working example of using Salesforce Rest API to make a call inside salesforce and create a “Lead” object record using “Postman”. Let’s Begin!!

Create a Connected App

Connected Apps allows external applications to connect to Salesforce over Identity and other DATA APIs. It utilizes the standard OAuth 2.0 protocol, can provide Single Sign-On and acquire access tokens for use by the various Salesforce supported APIs.

Note: We have to use this connected app because Apex REST Service inside salesforce cannot be accessed directly so it needs a link to be connected so we have use connected app

Steps to create a connected app

  • Go over to setup and type “Apps” in the search bar and click “App Manager”.
  • In the app manager, you will see an option as “New Connected App” button on the right top section of the screen.
  • Click the “New Connected App” button.
  • Give a meaningful name to your connected app. In this demo, I am giving the name as “Demo Connected App”.
  • Press the tab button and the API name will automatically get filled out.
  • In the “Contact Email” field, provide your email address.
  • Now scroll down a little into the page and you will see a section named as “API (Enable OAuth Settings)” and into that section, an option will be there named as “Enable OAuth Settings“, just check that checkbox.
  • In CallBack URL give the URL as ““. The Callback URL you supply here is the same as your Web application’s callback URL. In this case, as we are sending the request through postman the callback URL must be of Postman.
  • In the Selected OAuth scope section select the full access option and leave all other options as it is and click on save.
  • As you click on save you it will ask for a few minutes to set up and after that, you will get two more parameters that are used in this process of authentication that is Consumer Key and Consumer Secret.
  • Save them somewhere for future references.

Refer the video for steps:

Now In Postman, we have to generate an access token that can be used for calling out the service. Access token defines that we have used proper credentials to login into the account and we can proceed further. So to generate access token follow these steps:

  • Open the Postman App.
  • If you don’t have the app then you can download it from here Download_Postman
  • Assuming that you have the app up and running now Set Method to Post
  • Set the method URL to
  • In Body define these parameters (Key-Value Pairs)
  • grant_type : password
  • client_id: Consumer_Key
  • client_secret : Consumer_Secret
  • username: your_Salesforce_Account_username
  • password : password+security_token

If you don’t know what is security token and how to get your security token then please refer to this link. Reset Your Security Token