You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Smruti Koyande <sm...@cateina.com> on 2022/11/24 10:25:41 UTC

How to pass multiple JSON Payload in one request and reused the responses in another request.

Hello,

I want to pass multiple JSON Payloads in one HTTP request and use each of
that responses in separate requests one by one.

Is any solution to achieve this? If any need to write a script then please
guild me because I do not have much knowledge of coding

Ex.
I have one HTTP request (Encryption) which should accept multiple JSON
Payloads and I want to reuse the response in the other 4 requests of the
same thread group

[image: image.png]

Regards,
Smruti Koyande

Re: How to pass multiple JSON Payload in one request and reused the responses in another request.

Posted by Smruti Koyande <sm...@cateina.com>.
I have tried your 2nd suggestion. Used an extractor to extract data from
the response and stored it in one variable and call that variable in
another request as input JSON.
Buts its works with a single payload.

If I have one CSV file with 10 JSON Payloads(Encypted Payload) like
'EQV0wY8SsNcm4VvUOWpgk4QgfDPpXlNNw9I1rk2Cppxx5IugsRTXFIhI6QDSRlXsWNcELNtVmsVc9Ac8s+l9UfSKo8inWPEBW42cAv1p+Jag5zyq8pfwS38Dze1i5ruNsDgmDJ3D+Ek+udAJEEDAbw=='
Below is the the SS of my JSON Payload.
[image: image.png]
I want to use a one-by-one payload in another request.
Below is the SS of Sample HTTP requests
[image: image.png]


Regards,
Smruti Koyande






On Thu, Nov 24, 2022 at 4:10 PM Dmitri T <gl...@live.com> wrote:

> "I want to pass multiple JSON Payloads in one HTTP request" - JMeter
> doesn't restrict the number of "JSON Payloads" which you can send as the
> body in the HTTP Request sampler, moreover you are free to send absolutely
> anything. The question is whether the system you're testing is capable of
> parsing the "payloads", my expectation is that you're supposed  to send a
> *valid* JSON Object <https://www.w3schools.com/js/js_json_objects.asp> or
> (JSON Array <https://www.w3schools.com/js/js_json_arrays.asp>). We cannot
> help you without knowing the API contract of your encryption endpoint.
>
> If you want to get the full response from the endpoint into a JMeter
> Variable and re-use it in next requests just add a Boundary Extractor as a
> child of the request which response you want to store and provide the
> desired variable name, i.e. *response*. You will be able to refer it as
> *${response}* later on where required. If you want not the full response
> but rather a specific part from it - take a look at JSON Extractor
> <https://www.blazemeter.com/blog/json-extractor> or JSON JMESPath
> Extractor
> <https://jmeter.apache.org/usermanual/component_reference.html#JSON_JMESPath_Extractor>.
> Again we are not able to help without seeing the response and knowing which
> part of it you need to send
>
> In case you're seeking for a piece of advice regarding how to generate and
> read JSON programmatically take a look at Parsing and producing JSON
> <https://groovy-lang.org/processing-json.html> article.
> On 11/24/2022 11:25 AM, Smruti Koyande wrote:
>
> Hello,
>
> I want to pass multiple JSON Payloads in one HTTP request and use each of
> that responses in separate requests one by one.
>
> Is any solution to achieve this? If any need to write a script then please
> guild me because I do not have much knowledge of coding
>
> Ex.
> I have one HTTP request (Encryption) which should accept multiple JSON
> Payloads and I want to reuse the response in the other 4 requests of the
> same thread group
>
> [image: image.png]
>
> Regards,
> Smruti Koyande
>
>

Re: How to pass multiple JSON Payload in one request and reused the responses in another request.

Posted by Dmitri T <gl...@live.com>.
"I want to pass multiple JSON Payloads in one HTTP request" - JMeter 
doesn't restrict the number of "JSON Payloads" which you can send as the 
body in the HTTP Request sampler, moreover you are free to send 
absolutely anything. The question is whether the system you're testing 
is capable of parsing the "payloads", my expectation is that you're 
supposed  to send a *valid* JSON Object 
<https://www.w3schools.com/js/js_json_objects.asp> or (JSON Array 
<https://www.w3schools.com/js/js_json_arrays.asp>). We cannot help you 
without knowing the API contract of your encryption endpoint.

If you want to get the full response from the endpoint into a JMeter 
Variable and re-use it in next requests just add a Boundary Extractor as 
a child of the request which response you want to store and provide the 
desired variable name, i.e. *response*. You will be able to refer it as 
*${response}* later on where required. If you want not the full response 
but rather a specific part from it - take a look at JSON Extractor 
<https://www.blazemeter.com/blog/json-extractor> or JSON JMESPath 
Extractor 
<https://jmeter.apache.org/usermanual/component_reference.html#JSON_JMESPath_Extractor>. 
Again we are not able to help without seeing the response and knowing 
which part of it you need to send

In case you're seeking for a piece of advice regarding how to generate 
and read JSON programmatically take a look at Parsing and producing JSON 
<https://groovy-lang.org/processing-json.html> article.

On 11/24/2022 11:25 AM, Smruti Koyande wrote:
> Hello,
>
> I want to pass multiple JSON Payloads in one HTTP request and use each 
> of that responses in separate requests one by one.
>
> Is any solution to achieve this? If any need to write a script then 
> please guild me because I do not have much knowledge of coding
>
> Ex.
> I have one HTTP request (Encryption) which should accept multiple JSON 
> Payloads and I want to reuse the response in the other 4 requests of 
> the same thread group
>
> image.png
>
> Regards,
> Smruti Koyande
>