AllRounder.ai
Chapters in this course

Enrol to start learning

Reading is open to everyone. Enrolling is free, and it is what unlocks the audio lessons, practice tests and progress tracking.

Enrol free

11. API Testing Using Postman

Interactive Audio Lesson

Session 1: Understanding APIs

Unlock the classroom podcast

The transcript is free to read. A free account plays the conversation back.

Sarah
SarahInstructor

Welcome everyone! Today, we’re going to explore the concept of APIs. Can anyone tell me what an API is?

Noah
Noah

Isn't it something that allows different software to communicate?

Sarah
SarahInstructor

Exactly! An API, or Application Programming Interface, facilitates communication between software systems. This is especially important in QA to ensure everything is functioning correctly.

Isabella
Isabella

I heard there are different types of APIs. Which ones do we focus on in QA?

Sarah
SarahInstructor

Good question! In QA, we primarily deal with REST APIs, which follow the HTTP protocol and typically return data in JSON or XML format.

Akash
Akash

So, what does REST stand for?

Sarah
SarahInstructor

REST stands for Representational State Transfer. It has some important properties; for example, REST APIs are stateless, meaning each call is independent, and they rely on resource-based URLs.

Ananya
Ananya

That helps make it easier to work with them!

Sarah
SarahInstructor

Correct! Let’s summarize: APIs allow communication, and REST APIs are key in QA for their stateless, resource-based nature.

Session 2: HTTP Methods

Unlock the classroom podcast

The transcript is free to read. A free account plays the conversation back.

Robert
RobertInstructor

Now, let's discuss the common HTTP methods used with REST APIs. Can someone list them?

Noah
Noah

GET, POST, PUT, and DELETE?

Robert
RobertInstructor

Exactly! Each method carries a specific function. For example, GET retrieves data, while POST creates new data. Can anyone provide examples of when they might use these methods?

Isabella
Isabella

I would use GET to get all users from an API.

Akash
Akash

And I'd use POST to create a new user account!

Robert
RobertInstructor

Great examples! Remember: GET, POST, PUT, and DELETE form the basis of how we interact with APIs in a RESTful architecture.

Ananya
Ananya

Can you explain the PUT method again?

Robert
RobertInstructor

Sure! PUT is used to update existing data. For instance, if you wanted to update a user's profile, you would use PUT.

Noah
Noah

Okay, that makes sense! It’s all about CRUD operations!

Robert
RobertInstructor

Exactly! Let's recap: the key HTTP methods are GET, POST, PUT, and DELETE, each serving a unique purpose in API interactions.

Session 3: Using Postman

Unlock the classroom podcast

The transcript is free to read. A free account plays the conversation back.

Sarah
SarahInstructor

Next, we’ll look at how to use Postman for sending requests. Have any of you used it before?

Akash
Akash

I’ve heard of it but never used it!

Sarah
SarahInstructor

No problem! Postman has a user-friendly interface. You start with the Request Builder where you choose the HTTP method and enter the API URL. Let’s break this down.

Isabella
Isabella

What are the other tabs available?

Sarah
SarahInstructor

Excellent question! There’s the Headers tab for setting headers like Content-Type, the Body tab for including data, and the Params tab for adding query parameters.

Noah
Noah

And what do you do with the Send button?

Sarah
SarahInstructor

The Send button executes the request! After sending the request, you can view the response including status codes and the response body.

Ananya
Ananya

Can we look at a real example?

Sarah
SarahInstructor

Absolutely! If you select GET and enter the URL 'https://api.example.com/users', then click Send, you’ll see a JSON response of the users.

Akash
Akash

That seems simple enough!

Sarah
SarahInstructor

Reinforcing the key points, Postman’s Request Builder, Headers tab, Body tab, and Response Viewer are crucial for effective API testing.

Session 4: Assertions in Postman

Unlock the classroom podcast

The transcript is free to read. A free account plays the conversation back.

Robert
RobertInstructor

Now, let’s discuss how to write assertions in Postman. What do you think assertions are?

Isabella
Isabella

Are they checks to validate what the API returns?

Robert
RobertInstructor

That's correct! In Postman, assertions are written in the Tests tab using JavaScript. You can check for things like status codes or specific fields in the response.

Noah
Noah

Can you give a sample assertion?

Robert
RobertInstructor

Sure! For example, to check if the status code is 200, you would write: pm.test('Status code is 200', function() { pm.response.to.have.status(200); });

Akash
Akash

And how do we check if a specific field exists in the JSON response?

Robert
RobertInstructor

Great question! You could write something like: var jsonData = pm.response.json(); pm.expect(jsonData.name).to.eql('Charlie'); This checks that the response contains a field named name with the value Charlie.

Ananya
Ananya

So, we can automate the validation of APIs!

Robert
RobertInstructor

Exactly! Assertions are a powerful way to automate response validation, ensuring our APIs function correctly. Let's recap: Assertions in Postman allow you to validate various aspects of the response through JavaScript.