Back to All Questions
Question 46 of 100
Intermediate API Testing
Intermediate
Q46: How Do You Pass Data Between API Requests in Postman (Chaining)?
🔗Core Concept
How Do You Pass Data Between API Requests in Postman (Chaining)?
Key Takeaways & Architecture Summary
- ✓Extract variables in the Tests tab of Request A.
- ✓Store them using pm.environment.set("variableName", value).
- ✓Reference them in Request B using the dynamic variable syntax: {{variableName}}.
Direct Answer Summary
Passing data between requests (API chaining) involves programmatically extracting a value from Request A's response payload, storing it in an environment variable, and referencing that variable in Request B's URL, headers, or body using the `{{variableName}}` syntax.
⚠️ Senior Engineering Warning (Red Flag)
Never use hardcoded values in chained requests. Always automate variables dynamically, so your suite runs successfully from login to checkout without manual intervention.
💡 STAR Architectural Explanation & Pro Tip
Chaining mimics the real-world user lifecycle. For example, Request A logs in and retrieves a token; Request B uses the token to create a cart; Request C completes the checkout.
RestAssuredTest.java
Rest-Assured + Java// Request A Tests tab:
const userId = pm.response.json().id;
pm.environment.set("tempUserId", userId);
// Request B Configuration (Target Endpoint URL):
// GET {{baseUrl}}/api/v1/users/{{tempUserId}}/profile