Garth Egbert

API Testing: Postman

Blog Post created by Garth Egbert Expert on Sep 10, 2016

This information is really geared towards users who are trying to get started with the API.

 

I have seen questions in the community about the API, and have see Postman mentioned many times.  But, searching the Community I have not found any posts specifically about this tool and feel it might be worth talking about for those looking for a starting point.  My hope is that folks who are experienced with the tool can add to this information and further help new users get up to speed.

 

Postman Web App

Postman is easily accessible in Chrome through the Web Store.

If you haven't installed an app in Chrome before take a look at this article:

Install and manage apps - Chrome Web Store Help

 

To find the Postman web app and install it, search the Web Store for "Postman"

web-store-postman.png

 

Postman Native App

Postman also has a native app that you can install directly, which can be downloaded here:

Postman | Supercharge your API workflow

Personally I have not downloaded the native app yet, and have exclusively used the Chrome web app so far.

 

Postman provides documentation on installing the Chrome web app and the native app here:

Postman Docs - Getting Started

 

Authenticating With Your Token

To make an API call you will need to use your developer token to authenticate.

The following screen shot illustrates how to use the Headers to submit your token.

  1. Click on the "Headers" tab
  2. Enter the value "Authorization" for the key
  3. Enter "Bearer <token>" as the value

 

This screen shot also shows an example of the syntax to get a list of enrollments for a specific course, which you might want to use to test your token.

bearer-token.png

 

Example of a GET

You will need to tell Postman what type of API call you are making, i.e.GET, POST, PUT, whatever HTTP verb is associated with the API call.  The following screen shot shows an example of making a GET call to get the current status of an asynchronous job:  Progress - Canvas LMS REST API Documentation

 

In this case the API call is asking for the status of a content migration request.  You can see that GET has been selected as the type of API call being made, the authorization token has been provided, and the json results are displayed.

postman-get.png

 

Example of a POST

This is an example of a POST command to copy course content into another course:

Courses - Canvas LMS REST API Documentation

Notice in this screen shot that POST is selected.

postman-post.png

 

Example of a PUT

This might be useful, an API call to update a course:

Courses - Canvas LMS REST API Documentation

In this example, I am passing a parameter to publish/unpublish a course (which is useful in a script to publish all courses at the beginning of a semester).  Notice this time that PUT is selected in Postman.

postman-put.png

 

API Results

API results come back in JSON format.  JSON is notation representing object data.  If you are not familiar with JSON take a look at this W3Schools page for an overview:

JSON Syntax

 

W3Schools also has a tutorial here:

JSON Tutorial

 

Conclusion

This is basic info to help someone get started.  There is so much  more you can do.

Search Google for video walk-throughs to provide additional details.

Look through the Postman docs for tutorials and advanced techniques:  Postman Docs

 

Hopefully the info here will get you started, and community members will add their tips and tricks.

 

2016.11.14 - Update

If you would like to see source code showing how to implement the API in .NET, I have posted here:

For those who are interested in automating admin tasks and reporting, this might be useful.

Outcomes