jmeterjsr223

JMeter: Passing multiple variables in toPrettyString() function


JMeter: Need to send an array of random values from a CSV file

In continuation to the above question: Apart from passing random values from the CSV files in an array, some other parameters need to be passed as well, like below:

{"interest":["Mobility Testing", "BI Modernization", "Data Monetization"],"user_id":"8aafa3be-c19b-4355-88cb-1c068463790d","user_id_type":"wid"}

How can this be done?


Solution

  • You basically need to add a couple more entries to the LazyMap which holds your request payload.

    Change this line:

    def payload = new groovy.json.JsonBuilder([interest: entries]).toPrettyString()
    

    to this one:

    def payload = new groovy.json.JsonBuilder([interest: entries,
                                               user_id: '8aafa3be-c19b-4355-88cb-1c068463790d',
                                               user_id_type: 'wid']).toPrettyString()    
    

    More information: