0
votes

I'm new to Jmeter, and working on load test, I did couple of samples and that are running fine, Now I'm facing a Issue at below point.

Issue: How do I pass the variable in JSON body part?for few request we've a body and the body should change as per the input data, Ex: username and email, etc,.

I used ${name} kind of variable in Jmeter, but it's not working. Could you please suggest us the better way to rid out this issue.

Note: Please, refer the screenshot, where I wants to put a variable and that should come from user defined variables. click here to see image

Thanks in Advance, Rajesh B

Jmeter version: 5.1 Windows 10

{ "unitNumber": "111", "bathRooms": 1, "price": 50, "basePrice": 50, "streetAddress": "${ADDRESS}", "city": "Washington", "state": "CO", "address": "${ADDRESS_2}", "addressId": 2, "contactPreferedValue": "Email", "weekSelected": "1", "cleaningWeekSelected": "1", "email": "${Email}", "mobile": "", "weekSelectedValue": "May 30 2019", "keypadPasscode": false, "contactValue": "I'll be at home", "contactPrefered": 1, "isPaymentDone": false }

Expected result: Jmeter Script (JSON Body) should allow to read dynamic data from user defined variables.

2

2 Answers

1
votes

Please check you plan is same as below:-

enter image description here enter image description here

Hope this help.

Update:- It is the same logic. I have used your json in http request body and used user defined variable. I have got the below output. enter image description here enter image description here

0
votes

Use JSON Extractor from Post Processor to parse the JSON and store the value in a variable. Once you do that you can use the variable in required places

Please check the link bellow for details https://www.blazemeter.com/blog/api-testing-with-jmeter-and-the-json-extractor