'JMeter - How to pass output from HTTP Sampler as input to OS Process Sampler
I have a jmeter test plan with a pair of samplers. The first retrieves a keycloak token from an HTTP endpoint. The second is an OS Process Sampler that is supposed to take the response from the first sampler and remove the JSON artifacts from the response.
The first sampler works fine, I get the json-wrapped token returned. The second sampler is not operating on the output of the first as I had hoped. Here is the command:
jq .access_token -r
This command technically executes successfully, but there is no data in the response. I am guessing I had to somehow tell the OS Process Sampler to use the response of the HTTP sampler as input (from a curl command you would pipe the response from the HTTP call the to jq).
I would be grateful if someone knows how I get output of the first sampler as input to the second. Thank you
Solution 1:[1]
If this is really what you're looking for you can:
- Add Boundary Extractor as a child of the HTTP Request sampler and provide an arbitrary variable name, i.e.
responsethere - The response of the
HTTP Requestsampler will be available as${response}JMeter Variable and you will be able to use it anywhere else including OS Process Sampler
However be informed that JMeter comes with JSON Extractor and JSON JMESPath Extractor so you can extract your token from the JSON response using any of them, this way you will avoid unnecessary calling of the command-line interpreter, moreover you wont' have to rely on jq program presence on the machine where you will be running your tests.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dmitri T |
