What is Postman?
Postman is an API platform that is used for building and testing API's. This is very special tool for salesforce developer to test the api request and response.
Now, let us setup salesforce first.
Firstly we need to create a connected app in salesforce.
What is "Connected App" in salesforce?
For an external application that needs to authenticate with Salesforce we need to create a connected app so as to inform Salesforce about the new authentication entry point. Connected app uses standard OAuth 2.0 protocol to authenticate.
Go to setup > click app manager > "New Connected App" button.
Enter "Connected App Name", "API Name" and "Contact Email".
Click "Enable OAuth Settings".
Enter "Callback URL".
Select "Selected OAuth Scopes" as Manage user data via APIs (api)
Callback URL:
A callback URL is the URL that is invoked after OAuth authorization for the consumer (connected app). In some contexts, the URL must be a real URL that the client’s web browser is redirected to. In others, the URL isn’t actually used, but the value between your client app and the server (the connected app definition) must be the same.
In our case as we are using postman the callback URL will not impact us and we can write anything here, in our case we will use https://www.salesforce.com.
Note down the "Consumer Key" and "Consumer Secret".
Once you download the postman app, install it.
We are using "username password flow" to connect to salesforce org.
First step is to get access token.
If we are using production org we need to call the below URL to get access token with POST method.
https://login.salesforce.com/services/oauth2/token
If we are using sandbox org we need to call the below URL to get access token with POST method.
https://test.salesforce.com/services/oauth2/token
grant_type --> Must be the keyword "password" for this authentication flow.
client_id --> The Consumer Key from the connected app definition.
client_secret --> The Consumer Secret from the connected app definition.
username --> End-user’s username.
password --> End-user password + Security token
As an example, if password is YYYYY and security token is ZZZZZ then the value that will be
passed under password is YYYYYZZZZZ .
Once you click the "Send" button you will receive the response as shown below.
No comments:
Post a Comment