Set Up REST Client (Postman) - Hands-on Lab

Lesson 2 of 26 · 30 min

Before you begin:

This lab was also covered in the Catalog API course. If you already have Postman (or another REST client) installed and set up a sandbox environment with preset request headers, you can skip to step 3 where you will create an API token and update the request header preset.

Getting Started

In this lab, you will:

  • Create an OAuth token from your sandbox store’s control panel
  • Create a Postman account
  • Create an environment in Postman for your sandbox store
  • Update the preset request headers

Prerequisites

  • BigCommerce store (sandbox or live)
  • Basic knowledge of APIs
  • REST client (Postman)
  • Access to the user account with Store Owner permissions

Create an OAuth token from your sandbox store’s control panel

  1. Log in to your sandbox store

Make sure you are logging in using the user account with Store Owner permissions. For more information, see the Store API Accounts article in the support portal.

  1. Navigate to Settings > API Accounts
  2. Click the Create API Account button
  3. Select “V2/V3 API token” as the Token Type
  4. Type a name for the API account
  5. Copy the store hash from the API path

The store hash is the alphanumeric string in the API path between /stores/ and /v3/. This string uniquely identifies this store when sending requests to https://api.bigcommerce.com/

Example: API Path: https://api.bigcommerce.com/stores/abcd1234/v3/ Store Hash: abcd1234

The store hash can also be found in your Control Panel URL.

Example: Control Panel URL: https://store-abcd1234.mybigcommerce.com/ Store Hash: abcd1234

  1. Save the store hash somewhere that you can access to complete later steps in this lab activity
  2. Configure OAuth scopes by making the adjustments below:

For the purpose of the labs in this course, you can create one API token with all of the scopes listed below.

If you are working with one specific API you will only need to set the scopes for that API. See the BigCommerce Guide to API Accounts for more information.

Cart/Checkout and Payments API

ScopePermissions
Checkout ContentModify
Order TransactionsModify
Create PaymentsCreate
Get Payment MethodsRead-only
ProductsModify
CartsModify
CheckoutsModify

Orders API

ScopePermissions
OrdersModify
Order TransactionsModify
ProductsModify
  1. Click the Save button
  2. Copy the Client ID, Client Secret, and Access Token, then store them in a place you can access later

Image

A .txt file containing the same credentials will (on most browsers) automatically download to your computer.

There is no way to re-display this pop-up after you select Done to dismiss it. So make sure you store your credentials – either by copying/pasting the contents of each field out of the pop-up, or by keeping the downloaded .txt file. Otherwise, you will need to repeat all the above steps to generate new credentials.

From a security perspective, these credentials are sensitive – please treat them with the same caution that you would treat a private key or root password.

Getting Started with Postman

Postman

Create a Postman Account

  1. Navigate to postman.com
  2. Click Sign up for Free
  3. Fill out the form provided

Create an environment in Postman for your sandbox store

What are environments?

While working with APIs, you will often need to have different setups. For example, your local machine, the development server, or the production API. Environments give you the ability to customize requests using variables. This way you can easily switch between different setups without changing your requests. You won’t have to worry about remembering all those values once they are in Postman. Environments can be downloaded and saved as JSON files and uploaded later.

Source: https://learning.postman.com/docs/sending-requests/environments/managing-environments/

  1. If it is not already open, open Postman
  2. In the Workspace menu on the left side of the page, click the Environments tab

Image

  1. Click the + button to create a new environment
  2. Type a name, such as “My Sandbox Store” into the Environment Name field
  3. Create the following variables:

Environment Variables

VariableTypeInitial ValueCurrent Value
store_hashDefaultPaste your store hashPaste your store hash
v3_tokenDefaultPaste your Access Token copied from API account creationPaste your Access Token copied from API account creation
  1. Click Save
  2. Before you make a call, you must Assign the new environment. Above the Save button, Click the drop down arrow next to “No Environment.” Select your new environment to assign.

Update the preset request headers

Saving your request header information in a preset will allow you to quickly populate your request headers rather than having to re-enter this information.

  1. Open Postman
  2. Navigate to your workspace
  3. Click + to open a new tab
  4. Click on the Headers tab
  5. Click on Presets
  6. Click Manage Presets
  7. Click Add
  8. Add the following presets

Postman Presets

FieldValue
Acceptapplication/json
Content-Typeapplication/json
X-Auth-TokenAccess token (copied from API account creation)
  1. Click Add to save