简体   繁体   中英

How to send multiple post request using jmeter and json array?

I have this path in jmeter:

ctn_v2/wr/?${sid}&${pid}&f&${messageNumber}&${streamId}&${streamMessageId}&${dataFlagType}&subsid=${subsId}

what I want to do is to send multiple post request with different parameters using HTTP request with Jmeter. I am taking the parameters from JSON file which contain JSON array which each item in the JSON array has values which I want to send in a different post request. I used JSON path extractor to extract the values as follows (taken from DEBUG post sampler):

messageNumber_0=[0,1,2,4,3,5,6,7,8]
messageNumber_1=0
messageNumber_2=1
messageNumber_3=2
messageNumber_4=4
messageNumber_5=3
messageNumber_6=5
messageNumber_7=6
messageNumber_8=7
messageNumber_9=8
messageNumber_matchNr=9
msgSize=10
pid=2
protocol=https
sid=1600385571504156
streamId=[0,1,1,0,0,0,0,0,0]
streamId_1=0
streamId_2=1
streamId_3=1
streamId_4=0
streamId_5=0
streamId_6=0
streamId_7=0
streamId_8=0
streamId_9=0
streamId_matchNr=9
streamMessageId=[0,0,1,2,1,3,4,5,6]
streamMessageId_1=0
streamMessageId_2=0
streamMessageId_3=1
streamMessageId_4=2
streamMessageId_5=1
streamMessageId_6=3
streamMessageId_7=4
streamMessageId_8=5
streamMessageId_9=6

I want to be able to send the 1st post request with messageNUmber_0, streamId_0, etc... I tried to use 'counter' to resolve it but it didn't work out.

You can organize your Test Plan as follows:

In the HTTP Request sampler you can refer respective item names as:

  • ${__V(messageNumber_${counter})}
  • ${__V(streamId_${counter})}
  • and ${__V(streamMessageId_${counter})}

Demo:

JMeter合并变量

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