Skip to content
Tutorials Center
My learning

Topics

Lesson 10 of 37 ยท Test Plans and Samplers

The JMeter HTTP Request Sampler: GET, POST, Forms and Uploads

Master the JMeter HTTP Request sampler: methods, parameters, body data, file uploads, redirects, keep-alive, timeouts, embedded resources and how the Basic tab maps to a real request.

The HTTP Request sampler is the workhorse of JMeter. Nearly every web or API test is built from it, so understanding every field pays off. This lesson maps the fields on the sampler's panel to what actually goes over the wire.

Honesty note. JMeter cannot run here. Field names are those of the HTTP Request sampler in the 5.x series. The runnable blocks are stand-ins that build the request text from field values, so you can see how the panel translates to HTTP.

Add it with Add > Sampler > HTTP Request (under a Thread Group or controller).

The Basic tab

Field Meaning
Name Becomes the sample label in reports.
Protocol http or https. Blank uses defaults.
Server Name or IP Host, without protocol or path.
Port Number Blank means 80 or 443 by scheme.
Method GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS, TRACE and others.
Path Starts with /; may include a query string.
Content encoding Charset of the parameters, typically UTF-8.
Redirect Automatically Let the HTTP library follow redirects without recording them.
Follow Redirects JMeter follows redirects and records every hop as a sub-sample.
Use KeepAlive Reuse the TCP connection (on by default).
Use multipart/form-data Send POST parameters as multipart.
Browser-compatible headers Omit certain multipart headers for picky servers.

Under Advanced: Implementation (HttpClient4 by default; Java is simpler and older), Connect and Response timeouts in milliseconds, proxy settings, and Embedded Resources options (Retrieve All Embedded Resources, parallel downloads, URLs must match a regular expression).

Choose Follow Redirects (not Redirect Automatically) when you want to see each redirect, for example the login redirect chain, in results. Never tick both.

Parameters tab

For GET, list Name / Value pairs; JMeter appends them to the URL as the query string, URL-encoding values if the Encode? box is ticked. For POST form submissions the same table becomes the body a=1&b=2 with content type application/x-www-form-urlencoded.

Example: Path /search with parameters q=blue shoes and page=2 sends GET /search?q=blue%20shoes&page=2 (spaces encoded by the Encode? option). If a value is already encoded, leave Encode? unticked, or it will be double-encoded: a classic bug producing %2520.

Body Data tab

For JSON, XML or any raw payload, switch to Body Data and type the content. Pair it with a Header Manager entry Content-Type: application/json. Body Data and Parameters are mutually exclusive: if you add a parameter to a request that already has body data, JMeter moves it.

JSON
{
  "username": "${username}",
  "cart": [{"sku": "A-100", "qty": ${__Random(1,3,)}}]
}

Variables and functions work inside the body, which is how each user sends different data. Note that numbers in JSON do not need quotes, so ${__Random(1,3,)} produces valid JSON as long as it expands to digits.

Files Upload tab

Add a file by giving File Path, Parameter Name (the form field), and MIME Type. The request becomes multipart automatically for POST. The path may be relative to the plan's folder: put data files next to the .jmx so the plan works on every machine.

Seeing the real request

After a run, select the sample in View Results Tree and open the Request tab. It shows the request line, headers and body exactly as sent. When a server answers 400 Bad Request or 415 Unsupported Media Type, compare this to a working curl or browser request and fix the difference, usually a missing content type header.

The stand-in below builds the request text from panel-like fields, applying the rules above (query encoding, form body, JSON body).

JS Stand-in: turn sampler fields into an HTTP request

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Embedded resources

A browser loads a page, then its images, CSS and scripts. JMeter by default fetches only the HTML. Tick Retrieve All Embedded Resources and JMeter parses the HTML for resource links and fetches them, optionally in parallel (6 is a common browser-like number). Use it with a Cache Manager so resources are not re-fetched on every loop. The sampler's label then shows the main page as a parent and each resource as a sub-result.

If your content delivery network (CDN) serves static files, you may not want to hit it from a load test. Use URLs must match or URLs must not match regular expressions to include or exclude hosts.

Timeouts, retries and HTTPS

  • Always set a response timeout (for example 10 000 ms). Without one, a stuck request holds the thread indefinitely.
  • JMeter can retry failed requests with a Retries field in HttpClient4, but retries hide failures; keep it at 0 for honest numbers.
  • For HTTPS to hosts with self-signed certificates in a test environment, JMeter's default trust store may reject them; import the certificate into a keystore rather than disabling checks in production-like tests.
  • The built-in implementations speak HTTP/1.1. If you must measure HTTP/2 behaviour specifically, check the documentation of your JMeter version for HTTP/2 support or look for a community HTTP/2 plugin.

Several sampler variants

Beyond HTTP Request you will find AJP/1.3 Sampler (talking to Tomcat connectors), Access Log Sampler (replaying web server logs), and GraphQL HTTP Request (adds query and variables panes). Treat them as HTTP Request cousins.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which tab do you use to send a raw JSON payload?

    Body Data sends the text you type as the request body; set Content-Type through a Header Manager.
  2. 2. What problem occurs if you tick Encode? for a value that is already percent-encoded?

    Encoding twice turns the percent sign itself into %25, breaking the value.
  3. 3. How do you see each redirect hop as a separate sub-result?

    Follow Redirects makes JMeter follow and record each hop; Redirect Automatically hides them inside the HTTP library.
  4. 4. What does Retrieve All Embedded Resources do?

    JMeter parses the HTML for resource links and requests them, though it still does not run JavaScript.

Summary

  • The HTTP Request sampler maps panel fields to a real request: method, path, parameters, body or upload.
  • Use Parameters for form/query data, Body Data for JSON/XML, Files Upload for multipart.
  • Prefer Follow Redirects to see each hop; avoid double encoding.
  • Always set timeouts; keep retries at 0 for honest results.
  • Check the Request tab in View Results Tree to see what was really sent.

Next: Recording a Script with the HTTP(S) Test Script Recorder