For Admins: Running a Postman Collection

If there are multiple iterations of a single API call, each with different parameters, it makes sense to use a PostMan collection to automate those calls.

For example, this course:
https://uth.test.instructure.com/courses/26911

We want to undelete ten enrollments from a section in this course. The undelete command is:
POST https://uth.test.instructure.com/api/v1/sections/26959/enrollments?enrollment[user_id]=5227&enrollment[enrollment_state]=active

But the enrollments we want to undelete (by user id) are:
5227, 10564, 106, 10697, 12375, 12715, 1305, 1307, 1327, 1441

Step 1: Create a data file (csv) that looks like this:
userid
5227
10564
106
10697
12375
12715
1305
1307
1327
1441

Step 2: Move the POST command to its own folder in PostMan. It will be the sole API call in that folder/collection

Step 3: Modify the POST command to:
POST https://uth.test.instructure.com/api/v1/sections/26959/enrollments?enrollment[user_id]={{userid}}&enrollment[enrollment_state]=active
where the double curly braces mark the variable name in step 1
PARAMETER VALUES ARE CASE SENSITIVE!!!!

Step 4: Click "Runner" at the top of the PostMan screen to enter the collection runner

Step 5: Choose the collection you created in Step 2

Step 6: Select the data file you created in step 1

Step 7: Run the collection. It will run the API ten times, iterating through the values in the data file.

Comments

Popular posts from this blog

Canvas, Cidi (Kennethware) and Mobile-First

For Admins: Adding a new Catalog to Canvas Catalog