API Testing with POSTMAN

Using Environment Variables

Use this slide if there is no Heading
Note - Create Content inside Red Layout

[Delete Red Outline After creating slide]

Learning Outcome(Slide2)

5

Decide which method to use & when

4

Use Array Destructuring for clean code

3

Apply Rest & Spread operators confidently

2

Use map(), filter(), reduce() effectively

1

Perform CRUD operations on arrays

Topic Name-Recall(Slide3)

Hook/Story/Analogy(Slide 4)

Transition from Analogy to Technical Concept(Slide 5)

Environments in Postman

  • Environments in Postman are used to store variables that can change depending on where the API is being tested
  • Environment is a set of key-value pairs

Definition

  • Base URL, tokens, or user credentials might be different for Development, Testing, or Production

  • Instead of manually updating these values every time, Postman allows you to store them as variables inside an environment

  • This makes testing faster, Reduces manual effort

  • Helps avoid mistakes when working with multiple setups

Why Environments are Used

Chaining API Requests in Postman

Understanding the Concept

API request chaining is a technique where the output of one API request is used as an input for another request

Definition

APIs do not work independently in real-world applications

One request generates data required for the next request

Chaining API Requests in Postman

For example,

Key Idea

when a user logs in

This token is then used in other API requests to access protected resources

  • And use it in the next requests

  • Postman allows you to capture it automatically

  • Instead of referring this value manually

 the system returns an authentication token

 How Request Chaining Works

Extract values from the response of one request

Store them in variables

Use those variables in

Helps simulate real application flows

Makes testing smoother

  • Headers

  • Parameters

  • Request bodies

Using Test Scripts for Chaining

  • Implemented using test scripts in Postman

  • After request execution

let responseData = pm.response.json();
pm.environment.set("userId", responseData.id);

 Example

Response returns id

Stored in environment variable: userId

Used in next API request

  1. Script captures value from response

  2. Uses JavaScript

  3. Stores it as a variable

Real-World API Workflow

Create a user → API returns user ID

Login user → API returns authentication token

Use the token to access profile details

Update the user profile using the same user ID

1

4

3

2

Key Point

  • Values like user ID and token are reused across requests

Benefits of Request Chaining

  • Helps in end-to-end API testing

  • Useful for running collections

  • Works with

Collection Runner

Newman

  • No manual intervention required

  • Entire workflow runs automatically

Best Practices

Identify required response values

Extract values using scripts

Store in appropriate variables

Reference in next requests

Summary

5

Build strong branding

4

Use different marketing channels

3

Target the right audience

2

Create and communicate value

1

Understand customer needs

Quiz

Which platform is mainly used for professional networking and B2B marketing ?

A. Facebook

B. Instagram

C. LinkedIn

D. Snapchat

Quiz-Answer

Which platform is mainly used for professional networking and B2B marketing ?

A. Facebook

B. Instagram

C. LinkedIn

D. Snapchat

Using Environment Variables

By Content ITV

Using Environment Variables

  • 8