How to connect to Salesforce REST API with Postman ?

By: Published: October 26, 2021

Salesforce REST API Postman_Featured Image

One of the most important components of such a strategy is Customer Relationship Management (CRM), whose core tenet is to cater to the needs of your users to satisfy them and keep them happy at all times. Being able to use external applications such as Postman together with your CRM tool like Salesforce to achieve this level of satisfaction required by your customers is what this article is going to dwell on.

Postman is an API advancement environment that is used to test APIs, make robotized tests, get data or responses from your requests, and lots more. Connecting it with Salesforce through using the REST API goes a long way in helping you to manage your customers’ details effectively and reach out to them with tailored, specific information that suits them. 

In this article, you will be introduced to Postman and Salesforce. The steps involved to establish Salesforce REST API Postman will be discussed in detail. The advantages of Salesforce REST API Postman are also elaborated.

Table of contents

Introduction to Postman

Salesforce REST API Postman- Postman logo
Image Source: Salesforce

Postman is an Application Programming Interface (API) development tool that helps you build, test, and modify APIs. Postman can also be regarded as a collaboration platform that aids API development and helps in the creation of better and faster APIs by simplifying each step in the process of building an APIs therefore, allowing streamlined collaborative efforts.

Postman boasts of almost all functional tools needed by developers as they are encapsulated on the platform thereby making it a popular API platform used by over 5 million developers monthly. It can handle various types of HTTP requests ranging from GET, POST, PUT, to PATCH, converting the API to code for other languages like JavaScript, Python, etc. Postman can also save your environments for later use.

Introduction to Salesforce

Salesforce REST API Postman- Salesforce logo
Image Source: Wikipedia

Salesforce is a cloud-based Customer Relationship Management (CRM) platform that is used to create an avenue where companies can connect with clients, partners, and potential customers, bringing them together under one unit. 

Salesforce is used by marketing, sales, commerce, and service departments in corporations to ensure the company’s growth in marketing drives, increased sales, general commercial activities, and services.

Salesforce has a variety of modules such as Sales Cloud, Sales performance, Sales Collaboration, Marketing Cloud, etc. 

Salesforce is written in Java and uses the REST API protocol making it easy to use and it is highly customizable.

Simplify REST API ETL with Hevo’s No-code Data Pipeline

A fully managed No-code Data Pipeline platform like Hevo Data helps you integrate and load data from  100+ Data Sources (Including 40+ Free Data Sources) to a destination of your choice in real-time in an effortless manner. Hevo further provides a Native REST API Connector for free to help you load data from custom and non-native data sources to your desired destination without writing a single line of code.

Get Started with Hevo for Free

Hevo with its minimal learning curve can be set up in just a few minutes allowing the users to load data without having to compromise performance. Its strong integration with umpteenth sources allows users to bring in data of different kinds in a smooth fashion without having to code a single line. 

Check out some of the cool features of Hevo:

  • Completely Automated: The Hevo platform can be set up in just a few minutes and requires minimal maintenance.
  • Connectors: Hevo supports 100+ Integrations to SaaS platforms, files, databases, and BI tools. It supports various destinations including Amazon Redshift, Google BigQuery, Snowflake, and Firebolt Data Warehouses; Amazon S3 Data Lakes; and MySQL, SQL Server, TokuDB, DynamoDB, PostgreSQL databases to name a few.  
  • Real-Time Data Transfer: Hevo provides real-time data migration, so you can have analysis-ready data always.
  • 100% Complete & Accurate Data Transfer: Hevo’s robust infrastructure ensures reliable data transfer with zero data loss.
  • Scalable Infrastructure: Hevo has in-built integrations for 100+ sources that can help you scale your data infrastructure as required.
  • 24/7 Live Support: The Hevo team is available round the clock to extend exceptional support to you through chat, email, and support calls.
  • Schema Management: Hevo takes away the tedious task of schema management & automatically detects the schema of incoming data and maps it to the destination schema.
  • Live Monitoring: Hevo allows you to monitor the data flow so you can check where your data is at a particular point in time.
Sign up here for a 14-Day Free Trial!

Connecting Postman to Salesforce

Salesforce REST API Postman: Salesforce Connected App

Salesforce provides an avenue known as Connected App in which other applications can connect with the platform. A Connected App is defined as an application that allows external applications to integrate with Salesforce using APIs and standard protocol.

To create a Connected App on Salesforce, you will have to switch your Salesforce org from classic view to lightning experience as a new Connected App can be created only from the app manager in lightning experience. After you have performed the switch, do the following steps:

  1. In Salesforce org, navigate to Setup and search for apps, then Build, Create, and click on Apps.
Salesforce REST API Postman creating Apps
Image Source: appseconnect
  1. Go to the Connected Apps section.
Salesforce REST API Postman navigating to connected apps section
Image Source: appseconnect
  1. Choose the New Button to create a new connected app.
Salesforce REST API Postman- new button in the connected app
Image Source: appseconnect
  1. In the form, enter the required information such as Connected App Name, API Name, Contact Email for the application.
  2. Select Enable OAuth Settings checkbox.
  3. Provide a Callback URL and choose Access and manage your data (API) and move it from the Available OAuth scopes to the Selected OAuth scopes section.
  4. Click on Save and Continue.
  5. Click on your connected app.
  6. Take note of your Consumer Key and Consumer Secret present in the API (Enable OAuth Settings) as these would be required for authentication. The Consumer Key is visible directly but to get the consumer secret, click on the Click to Reveal link to see it.
Salesforce REST API Postman- Testing Postman
Image Source: sfdcstop

The Salesforce part of the connection has been completed and you will now move on to the Postman connection.

Salesforce REST API Postman: Setting Up Postman

To setup Postman, do the following:

  1. Go to https://getpostman.com/apps and download Postman for your operating system.
Salesforce REST API Postman- downloading Postman
Image Source: sfdcstop
  1. Once Postman is installed, open it.
Salesforce REST API Postman- working on Postman
Image Source: sfdcstop
  1. To connect to Salesforce org, two options can be used. Authorization Code Flow and Username Password Flow. 
  2. To use Username Password Flow, the next step is to get the access token. To get the access token through connecting with your developer org, use https://login.salesforce.com/services/oauth2/token as the URL to get it and when using the sandbox, use https://test.salesforce.com/services/oauth2/token as the token URL.
  3. Set the request method to POST to get access to your Salesforce org and in the body tab, make sure that the form-data radio button is selected then fill in the parameters:
    • Key:- username | Value:- <your login username for org> Salesforce org username.
    • Key:- password | Value:- < your orgs login password> Salesforce org password with a security token.
    • Key:- grant_type | Value:- password
    • Key:- client_id | Value:- <consumer key of your salesforce org’s connected app>
    • Key:- client_secret | Value:- <consumer secret of your salesforce org’s connected app>
Salesforce REST API Postman- working on Postman
Image Source: sfdcstop
  1. After filling in the values, click on Send. 

If everything goes correctly, you will have a successful login and you will get your instance_url, access_token, and token type in the JSON. The access_token is used as a  parameter in the header to send HTTP requests.

Nonetheless, in a case where it was not successful, you will get an error message as shown below:

{
 “error”: “invalid_grant”,
 “error_description”: authentication failure”
}

You will need to input your security token along with your password to log in get your access_token.

Salesforce REST API Postman: Retrieving Records from Salesforce in Postman

To retrieve a record from Salesforce through Postman, the GET method will be used and you will need to pass your instance URL. An example of the URL is shown below with its parameters:

https://instanceurl/services/data/v25.0/sobjects/Objectname/Id

  • instance URL: This is the instance URL you get from a successful login.
  • Objectname: This refers to standard objects like Account Name, Contacts, etc.
  • Id: This is the Salesforce ID of the particular record to be retrieved. 

To retrieve the record, do the following

  1. Put your instance URL which is obtained from your login to Salesforce through Postman in the URL box. 
  2. In the header of the request, input the access token and token type.
    1. Key:- Authorization | Value Bearer + access-token
  3. Click Send. 

Upon clicking send,  you will get details of the record in response to your request. 

Salesforce REST API Postman- Postman response
Image Source: appseconnect

Salesforce REST API Postman: Creating a New Record in Salesforce from Postman

To create a new record in Salesforce, you will use the POST method with your instance URL. A sample URL is shown below with explanations for the parameters:

https://instanceurl/services/data/v25.0/sobjects/Objectname

  • instance URL: This is gotten from a successful login response. 
  • Objectname: This is the particular object name that you are trying to create.

As stated above, the POST method will be used in creating a record and the following steps will be carried out:

  1. Get your instance URL and access token from your login in Salesforce through the Postman tool.
  2. Enter your instance URL in the URL box. 
  3. In the header of the request, pass the Content-Type parameter and the Authorization parameter.
    1. Key:- Content-Type  | Value: application/JSON
    2. Key:- Authorization  | Value: Bearer + access token. 
  4. Select POST method request. 
  5. Pass JSON data in the body of the request since it is a POST method request. 
  6. Hit the send button to get a response on the newly created record id.
Salesforce REST API Postman- create a record
Image Source: appseconnect
Salesforce REST API Postman- creating a record
Image Source: appseconnect

Advantages of Using Salesforce REST API Postman

The advantages of Salesforce REST API Postman are elaborated below:

  • Like the examples of GET and POST methods seen above,  all HTTP methods can be accessed using a custom API  through Postman. It gives you full control over all HTTP requests. 
  • There are no limits to file uploads as you can set headers and parameters, and use any content type such as binary, text, application, and so on.
  • Generation of code snippets for varieties of languages from your requests is possible on Postman.
  • You can build post execution scripts with JavaScript that can be used for setting environment variables.
  • It is easy to switch between multiple environments and whenever the switches occur, all variable values are updated to environment-specific values. For instance, you can have an environment for production and another one for a sandbox.
  • Postman allows you to collaborate on requests by importing/exporting your workspaces. It also has paid plans that couple Postman with source control for live collaboration.

Conclusion

The article has shown you how to connect Postman to Salesforce using the connected app in your Salesforce org and subsequently testing your custom API in Salesforce from Postman using the access token you derived from a successful log-in. By now you will have complete knowledge of Salesforce REST API Postman.

Doing all of these makes it easier for you to manage records on Salesforce as you can retrieve specific records based on your requirements and perform other operations, however, not having a firm understanding of the entire process can lead to drudgery. This is where Hevo Data comes in. Hevo Data is an all-encompassing data platform that can handle your data needs in an efficient and less complicated manner. It has several inbuilt connectors and integrators to a wide range of popular platforms inclusive of Salesforce.

Visit our Website to Explore Hevo

Hevo Data offers a faster way to move data from 150+ Data Sources such as REST API for free, into your Data Warehouse to be visualized in a BI tool. Hevo is fully automated and hence does not require you to code. Hevo provides a pre-built Native REST API Connector that will allow you to integrate data from a plethora of custom and non-native sources. All this without writing a single line of code and free of cost. To delve deeper into this subject, Explore our Salesforce Apex REST API.

Want to take Hevo for a spin? Sign Up here for a 14-day free trial and experience the feature-rich Hevo suite first hand. You can also have a look at the unbeatable pricing that will help you choose the right plan for your business needs.

Ofem Eteng
Freelance Technical Content Writer, Hevo Data

Ofem is a freelance writer specializing in data-related topics, who has expertise in translating complex concepts. With a focus on data science, analytics, and emerging technologies.

No-code Data Pipeline for REST API