How to connect to Salesforce via REST API using Postman ?

How to connect to Salesforce via REST API using Postman or Insomnia ? I have a trial version. I can't find this in settings.

What authentication type should I use ?

What endpoint should I use ?

What parameters should I use ?

How should the headers look like ?
0
give a positive ratinggive a negative rating
Hi,

You can use the following options to connect to Salesforce using REST API and Postman:

  • Create a Connected App manually - is a bit complicated, because of the settings
  • Import Salesforce platform API collection to Postman - contains many pre-defined profiles, requires some configuration, but is easier to use


Please note that API may not work / may not be fully supported in trial version. To work with Salesforce API for free, it is recommended to use a Developer version, which supports API connection and doesn't expire.


1. Create a Connected App manually

Sign into your Salesforce account, go to the settings and search for App Manager:

salesforce app manager step by step

Click on New Connected App:

salesforce create new connected app

Fill the required fields, enable OAuth Settings and set Callback URL to https://login.salesforce.com/services/oauth2/success:

salesforce create connected app rest api example

Choose the permissions (OAuth Scopes) and Save the app:

salesforce rest api permissions oauth scopes

Go to Manage Connected Apps and click on the created application:

salesforce manage connected apps rest api

Click on Manage Consumer Details to get the Consumer Key and Secret:

salesforce get consumer key and consumer secret

Consumer Key is later used as Client ID and Consumer Secret is used as Client Secret:

salesforce rest api postman client id client secret

Prepare your security token. If you don't have the security token, you have to reset it and receive it via email:

salesforce get security token reset

To connect to the Salesforce via API using a Postman, you have to first get the token. Check the Salesforce OAuth endpoints. When getting the token, you have to use the following params:

grant_type - "password"
client_id - use consumer key
client_secret - use consumer secret
username - your username
password - password+security token

salesforce rest api params in postman to get access token

The Headers should be set to:
Postman-Token: <calculated when request is sent>
Host: <calculated when request is sent>
content-type: application/x-www-form-urlencoded

You may also need to change some other settings to make a successful API call. If you are getting the error: {"error":"invalid_grant", "error_description":"authentication failure"}, you may need to set your API relaxation to Relax IP restrictions:

salesforce rest api ip relaxation

You also may need to allow OAuth username-password flows:

salesforce rest api oauth allow username password flows


2. Import Salesforce platform API collection to Postman

Go to the Salesforce API collections on Postman website. Then make a fork, to get the Salesforce API definitions to your Postman.

After the collection is available in your Postman, click on Authorization. Scroll down and click on Get New Access Token:

salesforce rest api postman authorization get new access token

You will be redirected to your Salesforce account. You may need to sign in. Then you have to allow access for Postman:

salesforce allow access postman

If your call is authenticated, you will get the success notification:

salesforce postman call authenticated

Then you will be redirected to Postman:

salesforce postman authentication complete

Click on Use Token:

salesforce postman access token rest api

Now, you should have an API access to your Salesforce account. To select the records, you have to click on REST folder in you Salesforce Platform API collection and choose Query:

salesforce postman rest api select query

You have to enter your SOQL query to get the records:

salesforce postman soql select query

You may get an error "Invalid URI". In this case, you have to check if {{_endpoint}} variable contains the value. If not, you have to set it in variables.
Share on FacebookShare on TwitterShare on LinkedInSend email
1 answer
x
x
2024 AnswerTabsTermsContact us