1

My JMeter version is the latest version 2.13. I would like to add an HTTP request to test my API, and the method is either PATCH or PUT.

In Postman, I can test the API and succeed using the PATCH method with some URL parameters.

For example:

URL: https://example.com/user/account
URL parameters: email ----> example@example.com
URL parameters: password ----> 12345678
Method: PATCH

This works in Postman/Paw but in JMeter I setup an HTTP request, add the parameters, and it fails.

How I can setup a working PATCH/PUT request with parameters in JMeter?

thesquaregroot
  • 1,414
  • 1
  • 21
  • 35
Anson Liao
  • 41
  • 1
  • 4

5 Answers5

3

I solved the problem with a temporary solution by adding the parameters to the HTTP request:

https://example.com/user/account?email=example%40example.com&password=12345678

and then delete the parameter in the HTTP request. It works now.

I hope I can find a formal solution to solve this.

JonyD
  • 1,237
  • 3
  • 21
  • 34
Anson Liao
  • 41
  • 1
  • 4
2

It seems that JMeter (at least as of version 2.13 r1665067) doesn't support passing parameters for PATCH requests using the "Parameters" table.

However, you can still pass parameters using the following workarounds:

  • If you want to have your parameters in the query string (GET-like), you can just append them to the path: /foo/bar?param1=2&param2=21.
  • If you want to have your parameters in the body (POST-like), you can switch to the "Body data" tab in the "HTTP Request" section and provide your encoded parameters there like this: param1=2&param2=21. Be sure to properly URL encode all parameters. Additionally you have to add a line to request header in the "HTTP Header Manager" section. Add the header Content-Type with the value application/x-www-form-urlencoded.
Lukas
  • 369
  • 3
  • 10
1

Just to complete/improve @Lukas answer, if you are importing the test parameters from a CSV file, you need to format the HTTP Request Path as follows:

/foo/bar?param1=${csv_param1_name}&param2=${csv_param2_name}

This needs to be done because, at least for PATCH requests, the parameters table is ignored.

This applies also to JMeter v4.0 r1823414.

bluish
  • 26,356
  • 27
  • 122
  • 180
JonyD
  • 1,237
  • 3
  • 21
  • 34
0

Jmeter uses the body data to fill with your data but no need a header, you can pass your data to backend. enter image description here

But I use httpServletRequest to get the parameter and it is empty, I don't know why...

  • I have used contentType "application/json" and put the data in request body ,now the controller can get the data with @RequestBody. note: the data should be json type. – Roderick Zheng Feb 28 '17 at 10:54
0

If you don't have to pass parameters through URL, you can also use 'Body Data' tab of 'HTTP Request' sampler of JMeter. It also supports placeholders. JMeter Patch Example

PS: I use JMeter Version 5.1.1