Requests in Postman

Table of contents
- 1. Request
- A) Request Method (HTTP methods) β
- B) Request URL π
- C) Authentication π
- D) Headers π
- E) Body π―
- F) Params Tab ποΈ
- π Example URL with Query Parameters
- β οΈ Important Notes:
- G) Tests and Scripts βοΈ
- Tests (Post-request Scripts)
- Pre-request Scripts
- π Summary Table
- H) Response Validation π
- 1οΈβ£ Status Code Validation
- 2οΈβ£ Validate Response Body
- 3οΈβ£ Validate Response Headers
- β Summary Table

1. Request
A request in Postman consists of a URL, method (GET, POST, PUT, PATCH, DELETE), headers, body, authentication, Scripts and parameters. This is what you send to an API to retrieve or modify data.
A) Request Method (HTTP methods) β
B) Request URL π
The Request URL is the full web address (Uniform Resource Locator) where the API server is hosted and where a particular resource can be accessed. It includes:
Base URL β the main address of the server.
Endpoint/Path β the specific API functionality/resource you want.
Optional Query Parameters β data you pass to filter or modify the request.
Example:
https://api.example.com/v1/users?role=admin
Part | Description |
https | Protocol (secure HTTP) |
api.example.com | Host/server address |
/v1/users | API path/endpoint |
?role=admin | Query parameter to filter users with role=admin |
C) Authentication π
Authentication proves who you are to the API. Without it, the server won't let you access or modify resources.
In Postman, you set authentication details in the Authorization tab or manually in the Headers tab.
1οΈβ£ API Key
A unique key provided by the API provider.
Sent in the header or as a query parameter.
Simple and widely used for basic access control.
Example (Header):
x-api-key: your_api_key
2οΈβ£ Bearer Token
A secure token (usually from OAuth 2.0).
Sent in the Authorization header.
Common in modern APIs like GitHub, Firebase, etc.
Example:
Authorization: Bearer your_token
3οΈβ£ Basic Authentication
Uses a username and password, base64 encoded.
Sent in the Authorization header.
Less secure unless used over HTTPS.
Example:
Authorization: Basic base64(username:password)
4οΈβ£ OAuth 2.0
A token-based, secure method for user authorization.
Requires getting a token through an authorization server.
Used by Google, Facebook, GitHub for login and data access.
D) Headers π
Headers are key-value pairs sent along with HTTP requests (and responses) that provide meta-information to the server and client.
They tell the server things like:
What type of data is being sent
What kind of response is expected
Authentication details
Caching, compression, and more
E) Body π―
The body is where you send data to the server, especially when you're:
Creating a new resource (POST)
Updating an existing one (PUT/PATCH)
Postman lets you format this body data in different ways, depending on the API requirements.
F) Params Tab ποΈ
Query parameters are key-value pairs added to the end of a URL to pass additional information to the server.
They are used mostly in GET requests, but sometimes in others as well.
π Example URL with Query Parameters
https://api.example.com/users?role=admin&active=true
?
starts the query parametersrole=admin
is one parameter&active=true
is another| KEY | VALUE | | --- | --- | | role | admin | | active | true |
β οΈ Important Notes:
Query parameters are part of the URL, not the body.
They are mostly used with GET requests.
Postman encodes values automatically (like spaces as
%20
).
G) Tests and Scripts βοΈ
Tests (Post-request Scripts)
Used to validate the response after the request is sent.
π§Ύ Common uses:
Check response status codes
Validate JSON data or fields
Save values to environment variables
Automate test cases for CI/CD
Pre-request Scripts
Used to run code before the request is sent.
π§Ύ Common uses:
Generate dynamic tokens, timestamps, or UUIDs
Set environment or global variables
Modify headers or params dynamically
π Summary Table
Feature | Tests (Post-request Scripts) | Pre-request Scripts |
Runs when? | After the request | Before the request |
Purpose | Validate response | Generate/set data for request |
Language | JavaScript | JavaScript |
Common use | Check status code, response data | Create tokens, set variables dynamically |
Location in Postman | Tests (Post-request) Script tab | Pre-request Script tab |
H) Response Validation π
1οΈβ£ Status Code Validation
When you make an API request, Postman lets you validate the response to ensure it's correct and expected. This includes checking:
β Status Code
π¦ Response Body
π Response Headers
2οΈβ£ Validate Response Body
You can validate:
Specific keys exist
Values are as expected
Arrays have items
π§ͺ Example:
let jsonData = pm.response.json();
// Check if key "name" exists
pm.test("Name field is present", function () {
pm.expect(jsonData).to.have.property("name");
});
// Check if value is correct
pm.test("Name is Sakshi", function () {
pm.expect(jsonData.name).to.eql("Sakshi");
});
3οΈβ£ Validate Response Headers
Headers contain info like content type, authorization, server name, etc.
π§ͺ Example:
pm.test("Content-Type is application/json", function () {
pm.response.to.have.header("Content-Type", "application/json");
});
β Summary Table
What to Check | How | Example |
Status Code | pm.response.to .have.status() | 200, 201, etc. |
Response Body Keys | pm.expect(jsonData). to.have.property () | Check field existence |
Response Body Values | pm.expect(jsonData.key).to.eql() | Match expected value |
Response Headers | pm.response.to .have.header() | Check header existence |
Subscribe to my newsletter
Read articles from SAKSHI RISHIPATHAK directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

SAKSHI RISHIPATHAK
SAKSHI RISHIPATHAK
I'm an experienced Software Development Engineer in Test (SDET) deeply passionate about DevOps practices. My focus lies in ensuring software quality through rigorous testing and automation. I leverage my background in software engineering to integrate DevOps principles, aiming to optimize efficiency and enhance collaboration across teams. I'm dedicated to continuous improvement and excited to contribute to advancing DevOps methodologies.