1

I have a list of order number's that I have got from one HTTP request.I need to extract all these numbers and use in my next HTTP request passing as an array

1
  • This is not a consulting or interview prep site. Give more details and show the code you have tried yourself. This is needed in order to help you. Otherwise others will shortly close this question. Jun 6, 2018 at 21:19

2 Answers 2

2

Your question is not very clear, in order to provide exact steps we need:

  1. Full (or partial) response for 1st request
  2. Exact format of parameter for 2nd request.

In the meantime here is how you can extract the whole response into a JMeter Variable so you will be able to re-use it somewhere else:

  1. Add Regular Expression Extractor as a child of the request which response you need to extract
  2. Configure it as follows:

  3. That's it, now you will be able to use the response from the previous request as ${response} where required.

0

Step 1: Add a post processor regular expression extractor to your get Http request and extract all order Ids .Use Match no -1 to store all order Ids.Assume that the name of the created variable is "Orders"

Step 2: Add a Beanshell pre-processor to your Post HTTP request and add the following code to the preprocessor

int count = Integer.parseInt(vars.get("Orders_matchNr"));

String delimiter = ",";
StringBuffer sb = new StringBuffer();
for(int i=1;i<=count;i++) { 
sb.append(vars.get("Orders_" + i));
if (i == count){
break; //to eliminate comma after the array
 }else {
 sb.append(delimiter);
 }
}
vars.put("arrayOutPut",sb.toString());

use [${arrayOutPut}] to pass as an array

enter image description here enter image description here

For more information on extracting variables follow this link

1
  • 1
    Thanks @Rohit it works for me!!!
    – MUSADDIK
    Jan 29, 2020 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.