Debug apps with Postman for MacOS

Postman is an OSX application that lets you send HTTP requests to Shopbase API endpoints. It can be a useful tool for getting started with the Shopbase API or for debugging your apps.

Get your Shopbase API credentials

To make authorized requests to the ShopBase API from Postman, you need to generate private API credentials

The scopes you grant when generate your API credentials will give Postman the equivalent permissions. Proceed with caution when granting write access.

Step 1: To generate private API credentials, create a private app:

( Consider skipping this part if you are already familiar with the content. )

Step 2: Send your API Credentials into Postman's New Tab :

  1. Click + to create a new tab.

  2. Click Authorization.

  3. From the Type drop-down menu, select Basic auth.

  4. In the Username and Password fields, enter your store's private API key and password respectively.

CAUTION

Don't enter the shared secret in place of the API password

After you've authenticated your request, you need to specify the applicable HTTP method and API endpoint URL before you can send it. For example, you can use Postman to retrieve your store information:

  1. From the request method drop-down menu, select GET.

  2. Enter the store API endpoint, where <store-names> is the name of your store:

    https://{store-names}.onshopbase.com/admin/shop.json

3.Click Send.

If the request was formatted correctly, then the store information is returned:

{
"shop": {
"id": 4159229,
"name": "John's Apparel",
"email": "johns-apparel@gmail.com",
"domain": "johns-apparel.com",
"created_at": "2014-03-27T17:52:33-04:00",
"province": "Ontario",
"country": "CA",
"address1": "150 Elgin St.",
"zip": "K2P1L4",
...
}
}

Add API credentials to an endpoint URL

Instead of entering your credentials in the Authorization section of Postman, you can paste a URL that includes your API key and password directly into the URL bar. The format of the URL is as follows, where <store-name> is the domain of your store:

https://apikey:password@<store-name>.onshopbase.com/admin/shop.json

When you click Send, the data is returned to Postman in the body of the response.

Creating Postman collections

After you've successfully sent an API request with Postman, you can save it into a collection. Collections group together related API calls and are a great way to organize your work in Postman.

To save an API request to a collection:

  1. In the tab for the API call you've just sent, click the arrow next to Save.

  2. Click Save As, then enter a Request name. You can also enter an optional description for the request.

  3. Click Create collection.

  4. Enter a name for your collection, then click the checkmark.

  5. Select the name of your collection.

  6. Click Save to (Name of your collection).

You can access your saved collections from the Collections tab in the sidebar.

TIP

Looking for a quick start? You can find details about all supported APIs in the Admin API reference.

Adding calls to Postman collections

After you've created a collection, you can add calls to help organize your API calls. For this example, you'll add a call that posts a product to your store.

To create a call and add it to your collection:

  1. Click + to open a new tab.

  2. From the Type drop-down menu, select Basic Auth.

  3. In the Username and Password fields, enter your store's private API key and password respectively.

  4. From the API actions drop-down menu, select POST.

  5. Enter the API endpoint for adding a product, where <@store_url> is the URL of your store:

  6. Click Body.

  7. Select raw, then in the drop-down menu, select JSON (application/json).

  8. In your browser, go to the Product reference

  9. Scroll down to the Create a new product POST call and copy the JSON of the IPod Nano - White, 8GB product.

  10. Paste the JSON in the Body of your Postman request.

11. Click Send. If the request is properly formatted, then the product response JSON will be returned to Postman.

NOTE

Shopbase prevents HTTP Basic Auth POST requests that have cookies, which can cause POST calls to fail. If your POST call fails, then you should try clearing your cookies.

Also note that the request headers automatically update to include Content-Type:application/json:

12. After the call has sent successfully, click the arrow next to Save. 13. Select the name of your collection. 14. Click Save to (Name of your collection).

You can add as many API calls to a collection as you want. You can access your saved collections from the Collections tab in the sidebar.

Next steps

Browse the Postman documentation to learn about collections and other features in more detail. You can also use Postman to help you build a public Shopbase app.