How to Simulate HTTP Requests and Extract Responses with JMeter
This guide walks you through creating a JMeter thread group, adding HTTP samplers, configuring listeners, using the JSON Extractor to capture response data, and handling multiple variables, enabling you to chain API calls and validate responses efficiently.
Http Request Simulation
1. Create Thread Group
Right‑click Test Plan → Add → Threads (Users) → Thread Group → rename the test plan.
2. Add HTTP Request Sampler
Right‑click the thread group → Add → Sampler → HTTP Request → fill in request parameters.
3. Start the HTTP Request
a. Add View Results Tree listener to see request results.
Right‑click thread group → Add → Listener → View Results Tree.
b. Click the green start button on the toolbar to run the test plan.
Note: The response data is shown as Text by default; you can switch to JSON Path Tester format.
Response Parameter Extraction
Often you need to use the response of one API as the request parameter of another, e.g., retrieve the ID of the first upcoming movie and then request its details.
Get the first movie ID: https://api.douban.com/v2/movie/coming_soon?count=2 Use the ID to request details:
http://api.douban.com/v2/movie/subject/${id}1. Add JSON Extractor Post‑Processor
Right‑click the "Get upcoming movies" HTTP request → Add → Post‑Processor → JSON Extractor → fill in variable names and other settings.
Enter variable names (e.g., id, year) and optionally default values.
2. Add HTTP Request Sampler to Retrieve Movie Details
3. Run the Test Plan
In the View Results Tree you can see that the request parameters are correctly populated and the response contains the expected data.
For multiple variables, separate variable names with a semicolon (;) and provide corresponding default values; otherwise the test may fail due to missing variables.
When using multiple variables, also fill in Default Values to avoid errors.
In this example, id and year are set with default values of 0.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Programmer DD
A tinkering programmer and author of "Spring Cloud Microservices in Action"
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
