![]() |
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 ParametersThese 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
Handling GET Requests with Query ParametersOpen Postman and create a new GET request:
![]() Postman Screenshot for GET Request Accessing Query Parameters in PostmanDirect Way : Automatically Detect when write full URL or Write it yourself in block ![]() Using Pre-request Script : Add this in ”the’test’portion.
![]() Example to showcase a servercreate a server using express use of node js App.js : having an endpoint ( GET )
That Video shows, how postman extract automaticaly parameters from URL Path ParametersEmbedded 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
Handling GET Requests with Path ParametersOpen Postman and create a new GET request:
![]() Postman Screenshot for Path Parameters Access Query Parameters in PostmanDirect Way : Gave input when writing full URL with ‘ :id ” , input id value ![]() Using Pre-request Script : Add this in ”the’test’portion. ![]() Body ParametersBody 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 : { Code Snippet:
Handling POST Requests with Body Parameters
{
![]() Postman Screenshot for Body Parameters: Access Query Parameters in PostmanDirect Way : That’s what we already provided as input ![]() Using Pre-request Script : Add this in ‘the test’ portion.
![]() SummaryUsing 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. |
Reffered: https://www.geeksforgeeks.org
Web Technologies |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 17 |