0
0
Postmantesting~5 mins

Path parameters in Postman

Choose your learning style9 modes available
Introduction

Path parameters let you send different values in the URL to get specific data. They help make your API requests flexible and dynamic.

When you want to get details of a specific user by their ID.
When you need to update a particular product using its product code.
When deleting a specific order by its order number.
When fetching comments for a specific blog post by post ID.
When accessing a resource that depends on a unique identifier in the URL.
Syntax
Postman
https://api.example.com/resource/{parameterName}

Use curly braces {} to mark the path parameter in the URL.

In Postman, you replace {parameterName} with actual values when sending requests.

Examples
Here, {userId} is a path parameter to get a specific user's data.
Postman
https://api.example.com/users/{userId}
This URL fetches items for a specific order using {orderId} as the path parameter.
Postman
https://api.example.com/orders/{orderId}/items
Fetch reviews for a product identified by {productCode}.
Postman
https://api.example.com/products/{productCode}/reviews
Sample Program

This example shows a GET request to fetch user details by replacing {userId} with 12345 in Postman.

Postman
GET https://api.example.com/users/{userId}

// In Postman, set path parameter userId to 12345

// Expected response:
// {
//   "id": "12345",
//   "name": "Alice",
//   "email": "alice@example.com"
// }
OutputSuccess
Important Notes

Always define path parameters clearly in your API documentation.

In Postman, you can add path parameters in the Params tab or directly in the URL by replacing the placeholders.

Path parameters are different from query parameters; path parameters are part of the URL path.

Summary

Path parameters make URLs dynamic by allowing variable parts.

Use curly braces {} to mark path parameters in URLs.

In Postman, replace path parameters with actual values before sending requests.