1. Set Up a Connected App in Salesforce
Purpose: Create an OAuth 2.0 app to authenticate Postman with Salesforce.
Steps:
-
Navigate to Setup → App Manager → New Connected App.
-
Fill in details:
-
Connected App Name:
BlogPostAPI
-
API Name:
BlogPostAPI
(auto-filled) -
Contact Email:
[email protected]
-
-
Enable OAuth Settings:
-
Callback URL:
https://oauth.pstmn.io/v1/callback
(Postman’s OAuth callback) -
Selected OAuth Scopes:
-
Access and manage your data (api)
-
Perform requests at any time (refresh_token)
-
- Flow Enablement: Enable Client Credentials Flow
-
-
Save → Note down:
-
Consumer Key (
3MVG9...
) -
Consumer Secret (
ABC123...
)
-
2. Get Access Token via Postman
Purpose: Obtain an OAuth token to authenticate API calls.
Request Setup in Postman:
-
Method:
POST
-
URL:
-
Production:
https://login.salesforce.com/services/oauth2/token
-
Sandbox:
https://test.salesforce.com/services/oauth2/token
- Dev Org: Goto Setup -> My Domain -> Current My Domain URL
-
-
Headers:
-
Content-Type: application/x-www-form-urlencoded
-
-
Body (x-www-form-urlencoded):
Key | Value Example |
---|---|
grant_type | client_credentials |
client_id | 3MVG9... (Consumer Key) |
client_secret | ABC123... (Consumer Secret) |
Save access_token
and instance_url
for later steps
3. Insert Blog Post via Salesforce REST API
Purpose: Send blog data from Postman to Salesforce.
Request Setup in Postman:
-
Method:
POST
-
URL:{{instance_url}}/services/data/v58.0/sobjects/Blog_Post__c/
(Replace
{{instance_url}}
with the one from Step 2) -
Headers:
-
Authorization: Bearer {{access_token}}
-
Content-Type: application/json
-
4. Retrieve Blog Posts (GET Request)
Purpose: Verify the data was stored correctly.
Request Setup in Postman:
-
Method:
GET
-
URL:{{instance_url}}/services/data/v58.0/query?q=SELECT+Id,Title__c,Subtitle__c+FROM+Blog_Post__c
-
Headers:
-
Authorization: Bearer {{access_token}}
-
5. Automate with Postman Collections & Environments
To avoid manually entering tokens:
-
Create a Postman Environment (
Salesforce_Dev
):-
Variables:
-
access_token
(from OAuth response) -
instance_url
(from OAuth response)
-
-
-
Use variables in requests:
-
{{access_token}}
in headers -
{{instance_url}}
in URLs
-
Troubleshooting Common Issues
Error | Solution |
---|---|
401 Unauthorized |
Refresh access_token (it expires in ~2 hours) |
404 Not Found |
Check object/field API names (case-sensitive!) |
INVALID_FIELD |
Verify field exists and is accessible to your profile |