Skip to main content

Lab-4-2

(1.67% of the course mark)

API testing using Postman

  • In this lab, participants will dive into API testing using Postman, a powerful and user-friendly tool for building, testing, and documenting APIs. The lab covers essential API testing concepts, focusing on GET, POST, PUT, and DELETE methods, as well as working with headers, parameters, and request payloads.

Lab objectives

  • Gain knowledge of RESTful APIs and HTTP methods.

  • Learn to navigate the Postman interface, create and organize requests.

Postman API testing GET method

  1. Open Postman and click on File >> New … >> HTTP Request.

  2. Choose GET from the HTTP methods drop down list.

  3. Enter this request url: https://jsonplaceholder.typicode.com/users and click on Send.

  4. The API response should have a list of users, Capture a screenshot of the result (should look similar to image below) and name it: get-request-many-users.png.

get-request-many-users
  1. Choose GET from the HTTP methods drop down list.

  2. Enter this request url: https://jsonplaceholder.typicode.com/users/1 and click on Send.

  3. The API response should have one user, Capture a screenshot of the result (should look similar to image below) and name it: get-request-one-user.png.

get-request-one-user
Lab Tips

JSONPlaceholder has other endpoints that you can use for mock api testing. For more information navigate to: https://jsonplaceholder.typicode.com/guide

Postman API testing POST method

  1. Open Postman and click on File >> New … >> HTTP Request.

  2. Choose POST from the HTTP methods drop down list.

  3. Enter this request url: https://jsonplaceholder.typicode.com/users.

  4. Click on Body, then click on raw and choose JSON from the drop down list.

post-man-settings
  1. Copy and paste the json string below to the request body and click on Send.
{
"name": "George Brown",
"username": "George.Brown",
"email": "George.Brown@georgebrown.ca",
"address": {
"street": "160 Kendal Ave",
"suite": "",
"city": "Toronto",
"zipcode": "M5R 1M3",
"geo": {
"lat": "",
"lng": ""
}
},
"phone": "416 415-2000",
"website": "https://www.georgebrown.ca/",
"company": {
"name": "George Brown College",
"catchPhrase": "The City is our Classroom",
"bs": "Learn by Doing"
}
}
  1. This should create a new user, Capture a screenshot of the result (should look similar to image below) and name it: post-request-one-user.png.
post-request-one-user

Postman API testing PUT method

  1. Open Postman and click on File >> New … >> HTTP Request.

  2. Choose PUT from the HTTP methods drop down list.

  3. Enter this request url: https://jsonplaceholder.typicode.com/users/1

  4. Click on Body, then click on raw and choose JSON from the drop down list.

post-man-settings
  1. Copy and Paste the json string below to the request body and click on Send.
{
"name": "John Smith",
"username": "John.Smith",
"email": "John.Smith@georgebrown.ca",
"address": {
"street": "160 Kendal Ave",
"suite": "",
"city": "Toronto",
"zipcode": "M5R 1M3",
"geo": {
"lat": "",
"lng": ""
}
},
"phone": "416 415-2000",
"website": "https://www.georgebrown.ca/",
"company": {
"name": "George Brown College",
"catchPhrase": "The City is our Classroom",
"bs": "Learn by Doing"
}
}
  1. This should update userid 1, Capture a screenshot of the result (should look similar to image below) and name it: put-request-one-user.png.
put-request-one-user

Postman API testing DELETE method

  1. Open Postman and click on File >> New … >> HTTP Request.

  2. Choose DELETE from the HTTP methods drop down list.

  3. Enter this request url: https://jsonplaceholder.typicode.com/users/1 and click on Send.

  4. This should delete userid 1, Capture a screenshot of the result (should look similar to image below) and name it: delete-request-one-user.png.

delete-request-one-user

Submission

  1. Create a folder named submit.

  2. Copy all (get-request-one-user.png, get-request-many-users.png, post-request-one-user.png, put-request-one-user.png and delete-request-one-user.png) the previously saved screenshots to this folder.

  3. Create a zip file of this folder.

  4. Navigate back to where the lab was originally downloaded, there should be a Submissions section (see below) where the zip file can be uploaded.

submission