简体   繁体   中英

How to pass both parameter and JSON in one single HTTP request body with having JSON a variable [JMeter]

I have a similar but extended question for the below question. How to pass parameter and json both in http request request body in jmeter? ?

I will take the same example as mentioned in the above question/link. Have to pass multiple parameters,

UserId=47
meeting={
    "DeviceID":${deviceID},
    "NetworkCarrierName":"VODAFONEIN",
    "BatteryValue":"22",
    "AppVersion":"1.1.3",
 }

As you can see, DeviceID have a value from variable deviceID. I want to pass all these parameters and JSON in one single http request body. What would be the approach for this?

In parameter I have to add the variable for value part for whichever key I want to refer to. It will work fine. This image shows that..

The same approach will work fine, you can use JMeter Variables anywhere in your test plan, if there is a User Defined Variable or a pre-defined variable or a variable coming from a Post-Processor - JMeter will substitute the variable placeholder with its respective value in the runtime:

在此处输入图像描述

If you're uncertain regarding how to properly build your request the easiest is just recording it using HTTP(S) Test Script Recorder

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