简体   繁体   中英

how to set multiple JSON request from the file in JMeter

I m newbie in JMeter. I am trying to send multiple JSON request using Jmeter where.

  1. Login (getToken) Request - I m loading a csv file for username and password

    { "Username": "${Username}", "Password": "${Password}",

    }

Response

{"Status":"Success","HttpStatus":200,"Data":{"token_type":"Bearer","token":"eITWDFHzN-awdaJy5SQ","name":"JMeter","u_ID":"6934FF18C130"}}
  1. AddQuery(Using #1 's response token and another parameter called U_ID )

for this I have request like this

 {

"Comment":"TEST COMMENT",
"Type":"TEST",
"DATE":"04-02-2020",   
"ColA":"",
"ColB":"",
"ColC":"",
"ColD":"",
"ColE":"",
 "User":"${name}"
} 

Here no of columns are diffrent. So I want to set up a plan where i want to read request JSON from the file. I tried with storing diffrent request in CSV file but JMeter is not able to read it.

I found if you storethe request in CSV file then it is adding extra " " like below.

JMeter request

POST data:
""{""Comment"":""TEST COMMENT"""

[no cookies]

Which is best way to handle/ ready JSON request from the file

Use __eval() and __FileToString() functions combination directly in "Body Data" tab of the HTTP Request sampler like:

${__eval(${__FileToString(/path/to/your/file.json,,)})}

在此处输入图片说明

where:

Demo:

在此处输入图片说明

More information: Here's What to Do to Combine Multiple JMeter Variables

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM