Setup Cross-Origin Resource in Salesforce
Need to add 2 URLs https://*.postman.com
and https://*.postman.co
to CORS for Salesforce to allow Postman requests. From the Setup screen, type cors In the Quick Find box.
- Click New.
- Enter
https://*.postman.com
. - Click Save .
- Add more
https://*.postman.co
as 1~3 - Click Save.
Set Up and Connect Postman
Sign Up to Postman and create a Workspace
- If you already have a Postman account, then log in to Postman with your account, if you don’t have an account, create a new Postman account and log in.
- Select Workspaces from the menu.
- Create a new Workspace.
- Name your workspace SalesforceCollection .
- Select Personal .
- Click the Create Workspace button.
Fork the Salesforce Collection
Open the public Salesforce Developers workspace and create a fork of the Salesforce APIs collection.
- In Collections, Select Salesforce Platform APIs and expand it.
- Click on the Fork icon to create a fork of this collection.
- Import MySalesforceAPIFork .
- Keep SalesforceCollection as the Workspace.
- Click the Fork Collection button.
Now this Salesforce Api collection is actually in your Postman. Next we need to connect this collection to SF via authorize.
Authorize
Need to authenticate with Salesforce to access APIs..
Make sure you are logged into an SF account in an open browser.
- In Postman, under Collections, select Salesforce Platform APIs .
- Open
Authorization
tab. - Select Type OAuth 2.0.
- Click the Get New Access Token button.
Authorization
screen appears
- Allow “Salesforce Platform APIs Collection for Postman” access to your SF.
- Click the Allow button
- The Manage Access Tokens Dialog is displayed. In Manage Access Tokens display information: Token Name, Access Token, Token Type, instance_url, issued_at, signature, and scope
- Copy
instance_url
to use in step 12. - Click the Use Token button.
- Open the
Variables
. - Paste the instance_url copied in step 9 into the
_endpoint
line of the CURRENT VALUE column. - Save.
KIỂM TRA