Detailed Step-by-Step Guide: Postman to Salesforce API Integration

Detailed Step-by-Step Guide: Postman to Salesforce API Integration

1. Set Up a Connected App in Salesforce

Purpose: Create an OAuth 2.0 app to authenticate Postman with Salesforce.

Steps:

  1. Navigate to Setup → App Manager → New Connected App.

  2. Fill in details:

    • Connected App NameBlogPostAPI

    • API NameBlogPostAPI (auto-filled)

    • Contact Email[email protected]

  3. Enable OAuth Settings:

    • Callback URLhttps://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
  4. 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:

  • MethodPOST

  • 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:

  • MethodPOST

  • 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:

  • MethodGET

  • 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:

  1. Create a Postman Environment (Salesforce_Dev):

    • Variables:

      • access_token (from OAuth response)

      • instance_url (from OAuth response)

  2. 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

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *