How to Access Request Parameters in Postman?
Request parameters are additional pieces of information sent along with a URL to a server. They provide specific details about the request, influencing the server's response. Parameters typically follow a 'Key=Value' format and are added to the URL in different ways depending on their type.
Table of Content
Query Parameters
These parameter are appended to the URL after a question mark (?). Used for optional information or filtering results.
Example: Fetching a list of users with a specific age range:
https://api.example.com/users?age_min=25&age_max=35
userId=12345 and status=active are query parameters.
Code Snippet: Extracting in Express
const userId = req.query.userId;
const status = req.query.status;
Handling GET Requests with Query Parameters
Open Postman and create a new GET request:
- Set the HTTP method to GET.
- Enter the URL: https://postman-echo.com/get.
- Click on the Params tab.
- Add userId with value 12345 and status with value active.
- Send the request.

Accessing Query Parameters in Postman
Direct Way : Automatically Detect when write full URL or Write it yourself in block

Using Pre-request Script : Add this in ''the'test'portion.
let url = pm.request.url.toString();
let params = {};
if (url.includes('?')) {
let queryString = url.split('?')[1];
queryString.split('&').forEach(param => {
let [key, value] = param.split('=');
params[key] = value;
});
}
console.log(params);

Example to showcase a server
create a server using express use of node js
App.js : having an endpoint ( GET )
const express = require('express');
const app = express();
// Define a route to handle GET requests with query parameters
app.get('/api', (req, res) => {
// Extract query parameters from the request
const userId = req.query.userId;
const status = req.query.status;
// Log the extracted parameters to the console
console.log(`UserId: ${userId}, Status: ${status}`);
// Send a response back to the client with the received parameters
res.send(`Received userId: ${userId}, status: ${status}`);
});
// Start the server on port 3000
app.listen(3000, () => {
console.log('Server running on port 3000');
});
That Video shows, how postman extract automaticaly parameters from URL
Path Parameters
Embedded directly within the URL path, denoted by colons (:). Used to identify specific resources within a URL structure.
Example: Retrieving details of a user with a specific ID:
https://api.example.com/users/:id (where ":id" is replaced with the actual user ID)
Code Snippet: Extracting in Express
app.get('/api/users/:userId', (req, res) => {
const userId = req.params.userId;
res.send(`UserId: ${userId}`);
});
Handling GET Requests with Path Parameters
Open Postman and create a new GET request:
- Set the HTTP method to GET.
- Enter the URL: https://jsonplaceholder.typicode.com/todos/:id.
- Click on the Params tab.
- Add an ID with a value 5.
- Send the request

Access Query Parameters in Postman
Direct Way : Gave input when writing full URL with ' :id " , input id value

Using Pre-request Script : Add this in ''the'test'portion.

Body Parameters
Body parameters are included in the body of an HTTP request, typically used with POST, PUT, or PATCH requests. For example, sending JSON data in a POST request. typically in formats like JSON or form data. Used for sending the main data payload of the request.
Example: Creating a new user with name and email details:
https://api.example.com/login/
Body detail :
{
"name": "John Doe",
"email": "john.doe@example.com"
}
Code Snippet:
const { name, email } = req.body;
Handling POST Requests with Body Parameters
- Set the HTTP method to POST.
- Enter the URL: https://postman-echo.com/post.
- Click on the Body tab.
- Select raw and JSON formats.
- Enter the JSON data:
{
"userId": "12345",
"status": "active"
}
- Send the request

Access Query Parameters in Postman
Direct Way : That's what we already provided as input

Using Pre-request Script : Add this in 'the test' portion.
const requestBody = pm.request.body.raw;
const bodyParams = JSON.parse(requestBody);
const userId = bodyParams.userId;
const status = bodyParams.status;
console.log(`UserId: ${userId}, Status: ${status}`);

Summary
Using pre-request scripts in Postman, you can access and manipulate request parameters before sending the actual request. This is useful for setting up test conditions, modifying requests dynamically, and performing pre-request validations. The examples provided show how to handle query, path, and body parameters, making your API testing more robust and flexible.