How to Store multiple id from one request and retrieve few id for update within the same thread in jmeter?

  • My Scenario. [ All are in Same Thread group] I have to Create Cart, Add Multiple Items(5), Update few items(1) and then checkout.

    Add Items - I have to add 5 Items [ Each Item will generate unique Item ID] Using For Loop to add 5 times and capture the Item ID value using JSON Extractor. Variable Name= C_Item_ID

    JSON Path Expression= $.items[0].id

    In JSR223 Postprocessor, i having the below code

    def count_value= vars.get("cnt").toInteger(); //convert to int type

    For each loop iteration i am capturing the Item ID and store it different variable

    switch (count_value) {

         case 1:
           def C_Item_ID_1 = vars.get("C_Item_ID");

    Update Item - I need to passing the unique Item ID here.

    ex. xxx-service-xxx/cart/1234567890/items/${C_Item_ID_1}

    When i reply "${C_Item_ID_1}" value is not getting here.

    Not sure what is wrong on this? Any help?

  • After multiple tries the below solution working fine and successfully executed the method and getting correct response.


    Thank you all for the support.

Log in to reply

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2