1
votes

I have HTTP request whose response is below

{
  "DATA": {
     "G_1": {
      "OR_ID": "100400",
      "LEGAL_ENTITY": "TEST",
      "BUSINESS_UNIT": "TEST BU"
    },
    "G_2": {
      "OR_ID": "100500",
      "LEGAL_ENTITY": "Test1 ",
      "BUSINESS_UNIT": "Test1 "
    },
    "G_2": {
      "OR_ID": "100100",
      "LEGAL_ENTITY": "TEST3 ",
      "BUSINESS_UNIT": "Test3"
    }
}

I need to get OR_ID from the above response, which I am able to do it using Regular exp extractor.

There is Input CSV file which has multiple rows. For the CSV file, i need to check the OR_ID exists or not in column 2, if exists then I have to take columns 5 and 7 and pass it to my next post request in the body. In CSV the same OR_ID repeated, so i need repeat post request for all the repeated values of OR_ID in csv. CSV file has no header.

441919244,100010,QUTRN,TEST Inc.,100100,TEST,VCG and A, INC,USD,3409.0900,O,ICO-VCG-0140,2019-10-31,52 945,USD,USD,359409.0900,359409.0900,359409.0900,Processed,93901372,File,2019111NG52.csv,
441919028,100400,QUQED,TEST MEDICAL EDUCATION INC.,100020,QUINC,TEST INC.,USD,12.340,O,ICO-INC-8718,2019-10-31,52 729,USD,USD,12.3400,12.3400,12.3400,Processed,93901372,,File,20191113NG52.csv, 

Can you please help.

1

1 Answers

1
votes

Assuming that you can extract the OR_ID from the JSON response following solution could be useful.

  1. In the CSV Data Set Config Element or Random CSV Data Set Config plugin read the CSV file assign the variable names to the respective columns

variable names = C1,OR_ID,C3,C4,C5,C6,C7,C8,C9

  1. Add a While Controller as a parent to the CSV Data Set config elements and the HTTP Request where you want to send data from the CSV file.

${__jexl3("${OR_ID}"!="EOF")} This will check EOF in the column 2 of the CSV file. Hence please add ,EOF,, as the last line of the CSV file.

  1. Add IF controller to the HTTP Request with following condition

${__jexl3("${OR_ID}"=="${OR_ID_J}")}

OR_ID_J is the OR_ID picked from the JASON response.

  1. Use ${C5} and ${C7} in the places where you want to insert the data from the CSV file.

  2. Reset the OR_ID to "" using a JSSR223 Sampler with following

vars.put("OR_ID", "");

Sample Test Plan is available in GitHub