Prerequisites

What You'll Learn

Learning Objectives

Why Use Postman to Access the Salesforce Platform APIs?

Salesforce exposes a rich set of application program interfaces (APIs) that integrate with third-party systems. All of these APIs are thoroughly documented, but how can you quickly try them on a given org, or better yet, on multiple orgs? Postman helps you discover, explore, and test integration options with the Salesforce Platform APIs.

About Salesforce Platform APIs

Salesforce provides programmatic access to your org's information through simple, powerful, and secure APIs. The APIs provided by Salesforce include REST, SOAP, Connect, User Interface, Analytics, Bulk, Metadata, and Streaming.

About Postman

Postman is an application that you can use to configure and call HTTP-based APIs, such as REST or SOAP. You configure this powerful tool in an easy-to-use graphical user interface. It supports environment variables, team workspaces, and JavaScript automation.

Web or Desktop?

Use Postman as a desktop app or in a web browser. In this project, you set up and use Postman in a web browser, because it doesn't require downloading and installing software.

About the Salesforce Platform APIs for Postman Collection

The Salesforce Platform APIs for Postman collection is a resource that wraps together 200+ request templates for many Salesforce Platform APIs. This open source collection uses the configurable Postman environment and variables so that you can easily authenticate and try the requests on multiple Salesforce orgs.

Create a New Trailhead Playground

For this project, you need to create a new Trailhead Playground. Scroll to the bottom of this page, click the playground name, then click Create Playground. It typically takes 3–4 minutes to create a new Trailhead Playground.

Get Your Trailhead Playground Username and Password

Let's get started by opening your Trailhead Playground. Scroll to the bottom of this page and click Launch. If you see a tab in your org labeled Get Your Login Credentials, great! Skip ahead to step 1. Otherwise, from the App Launcher, find and open Playground Starter and follow the steps.

  1. Click the Get Your Login Credentials tab and take note of your username.
  2. Click Reset My Password.
  3. This sends an email to the address associated with your username.
  4. Click the link in the email.
  5. Enter a new password, confirm it, and click Change Password.

Save your username and password for use later in this project.

Set Up Cross-Origin Resource Sharing in Salesforce

Cross-Origin Resource Sharing (CORS) allows code running in a web browser to communicate with Salesforce from a specific origin. Let's add the URL patterns for Postman.

  1. In your Trailhead Playground, from Setup, enter cors in the Quick Find box and select CORS.
  2. In the Allowed Origins List, click New.
  3. Enter https://_.postman.com as the Origin URL Pattern.
  4. Click Save.
  5. Select CORS again.
  6. Click New and enter https://_.postman.co (note the .co domain extension) as the Origin URL Pattern.
  7. Click Save.

Your playground is ready for you to connect Postman to it. You do that in the next step.

Sign Up for Postman and Create a Workspace

Postman has two options for working with its app: desktop and web. You use the web browser app for this project.

  1. Sign in to your Postman account or sign up for an account.
  2. Select the Workspaces menu.
  3. Select Create Workspace.
  4. Name your workspace SalesforceCollection.
  5. Set Visibility to Personal.
  6. Click Create Workspace.

Fork the Salesforce Collection

  1. Open the public Salesforce Developers workspace to create a fork of the Salesforce APIs collection.
  2. In Collections, select Salesforce Platform APIs to expand it.
  3. Click the Create Fork icon to create a fork of the collection.
  4. Enter MySalesforceAPIFork.
  5. Keep SalesforceCollection as the Workspace.
  6. Click Fork Collection.

You now have the collection ready in Postman. Let's use the collection to authorize your org and test it.

Authorize Your Org

You need to authenticate with Salesforce to access the APIs. Authentication grants you an access token that's valid for a certain duration. Repeat this process whenever your access token expires.

  1. Be sure you're logged in to only one Trailhead Playground in your browser.
  2. In Postman, under Collections, Salesforce Platform APIs should be selected.
  3. The Authorization tab should be open.
  4. Type should be OAuth 2.0.
  5. Click Get New Access Token.
  6. Click Allow to let the "Salesforce Platform APIs Collection for Postman" access your Trailhead Playground allow access
  7. A success message appears briefly, and then you're redirected to the Manage Access Tokens dialog. tokens dialog
  8. Verify that the instance_url points to your Trailhead Playground.
  9. Copy the instance_url to use in step 12. Be sure to copy only the URL with no extra characters.
  10. Click Use Token.
  11. Open the Variables tab.
  12. In the _endpoint row, CURRENT VALUE column, paste the instance_url value that you copied in step 9.
  13. Click Save.

A Quick Connection Test

Let's verify that the connection is working.

  1. In Collections, select Salesforce Platform APIs to expand it.
  2. Select REST to expand it.
  3. Select GET Limits. Limits opens in the main panel.
  4. Click Send. send request
  5. Verify that the status is 200 OK.

You've successfully authenticated with Salesforce. Now you can use other requests in the collection.

Post an Account

You just pulled some data from the org. Let's try adding some new data to the org.

  1. Under REST, select SObject, and then select POST SObject Create.
  2. Open the Params tab.
  3. Under Path Variables, in the SOBJECT_API_NAME row, VALUE column, enter Account.
  4. Open the Body tab.
  5. Replace the body text with this code:
    {
      "Name": "Postman",
      "BillingState": "CA"
    }
    
  6. Click Save.
  7. Click Send. Postman returns the id for the new account. returns id
  8. Verify that the status is 201 Created.

Excellent! You've set up Postman to interact with your org. The Salesforce APIs for Postman collection that you loaded will aid you in your quest to discover the Salesforce APIs.

This course was originally created by Salesforce and has been modified to suit the Quickstart format. Complete this lesson in Trailhead to collect your Salesforce learning badge.

Resources

What we've covered