As we use REST API in Salesforce for API Integration. Before you proceed with any work related to API, you should check the REST APIs. Today, we will learn how to test the Salesforce Rest API with the Postman Tool. So first let’s see what is Postman, and then we will see how to test the Salesforce Rest API with it.
Postman
Postman is a popular collaboration platform that provides a user-friendly graphical interface for creating HTTP requests and responses and allows developers to quickly and easily test and debug their APIs. You can download Postman from here.
There are several reasons why Postman is commonly used for this purpose:
● User-friendly Interface
● Automation
● Collaboration
● Debugging
● Documentation
How to test Salesforce Rest API
Here are the three simple steps to test the Salesforce Rest API:
● Create a connected app for OAuth.
● Get Access Token in Postman.
● Test Salesforce Rest API using Postman.
Let's get started.
1. Create a connected app for OAuth
A connected app is an application that is registered in Salesforce and used to authenticate external applications or services using OAuth.
The steps to connect the app for OAuth are as follows -
● Go to setup and enter App manager and click App Manager
● Click the new Connected app.
● Give the connected app name, and email. Enable the OAuth setting then pass the callback URL and select the OAuth scope you want to give for now we will be giving ‘full Access (full)’ then click the save button. Then click continue to get details.
2. Get an Access Token in Postman
We will provide the access token to authenticate API requests to the web service. Below are the steps to get an access token in Postman:
1. Open Postman and create a new request or open an existing one.
2. Click on the "Authorization" tab.
3. From the "Type" dropdown, select "OAuth 2.0".
4. In the "Configuration Access Token" dialog box, enter the required information, such as the token name, authorization URL, token URL, client ID, client secret, and scope.
5. Click on the "Get New Access Token" button.
6. Click on the "Request Token" button.
7. If the authentication is successful, Postman will display a list of available scopes.
8. Select the desired scope(s) and click on the "Use Token" button.
9. Postman will add the access token to the Authorization header of the API request.
3. Test Salesforce Rest API using Postman
You need to set the method and URL for API then click on send button
Now we will use get request to test the @HTTPget request
Now we will use post request to test the @HTTPPost request
So, this is the way to test RestApi using the Postman tool. Happy!! to help you add to your knowledge. You can leave a comment to help me understand how the blog helped you. If you need further assistance, please contact us. You can click "Reach Us" on the website and share the issue with me.
References:
Blog Credit:
C. Baghel
Salesforce Developer
Avenoir Technologies Pvt. Ltd.
Reach us: team@avenoir.ai
Commenti