- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is Pre-Request Script in Postman?
The Pre-Request Script is used to run a JavaScript prior to the execution of a request. By incorporating a Pre-Request Script for a Collection, request or a folder, we can execute precondition steps like defining a variable, Parameters, Headers, Response, or logging console output.
We can include a Pre-Request Script to set the order of execution of requests within a Collection. A Pre-Request Script can also handle a scenario in which a value yielded from the request one has to be fed to the next request or the value yielded from the request one has to be processed before moving to the next request.
A Pre-Request can also be utilized to set a value from the Response field to a variable linked to a script in the Tests tab. These scripts are defined in the Pre-request Script tab in Postman.
Add the below JavaScript in the Pre-Request Script tab −
console.log("This is a Postman Tutorial in Tutorialspoint")
Select a GET request and enter an endpoint then click on Send.
Postman Console Output:
Pre-Request Script to Collections
Step1 − Click on the three dots beside a Collection in the sidebar. Then click on Edit.
Step2 − EDIT COLLECTION pop-up comes up. Click on the Pre-Request Scripts tab to add a pre-condition script. Then click on Update.
- Related Articles
- Creating Variables using Pre Request Script using Postman?
- What is Pre Requests scripts in Postman?
- How to see request logs in Postman console?
- How to use Global Variable in Postman Request?
- How to create a PUT request in Postman?
- How to create a DELETE request in Postman?
- How to create a POST request in Postman?
- How to share Session ID Cookie with another request using Postman?
- What is Newman in Postman?
- How to set Multiple Tests for a Request in Postman with JavaScript Method?
- What is Postman Sandbox?
- What is Postman Console?
- What is API Documentation in Postman?
- What Is Pre-existing cell
- What is a request object in JSP?
