Reputation: 21
I have to pass a JSON in the HTTP request and that JSON contains an array of addresses. Up until I add the array, the request is fine and I do get a response but as soon as I add the array of addresses, I get a bad request error
Below is my bad request
{
"searchType": "XXXXXX",
"searchCriteria": {
"firstName": "J",
"lastName": "S",
"birthYear": 1980,
"birthMonth": 1,
"birthDay": 1
"addresses":{
"address": [
{
"_city": "LOUISVILLE",
"_state": "TN",
"_zip": "37777-3917"
},
{
"_address1": "920 E LAMAR ALEXANDER PARKWAY",
"_city": "MARYVILLE",
"_state": "TN",
"_zip": "37804"
},
{
"_address1": "Last Reported Address - Out of State",
"_city": "LOUISVILLE",
"_state": "TN",
"_zip": "37777"
}
]
}
},
"identification": {
"ipAddress": "XXXXXXXX",
"applicationID": "XXXX"
}
}
Can someone please guide me how this can be achieved in Jmeter?
Upvotes: 1
Views: 793
Reputation: 168157
What you provide is not a valid JSON you can double check it using an online JSON validator
Since we don't have any idea regarding how the "good" request should look like we cannot come up with the 100% valid solution.
You can try to use the below JSON payload as the reference, it's syntactically correct but I don't guarantee your application will accept it:
{
"searchType": "XXXXXX",
"searchCriteria": {
"firstName": "J",
"lastName": "S",
"birthYear": 1980,
"birthMonth": 1,
"birthDay": {
"addresses": {
"address": [
{
"_city": "LOUISVILLE",
"_state": "TN",
"_zip": "37777-3917"
},
{
"_address1": "920 E LAMAR ALEXANDER PARKWAY",
"_city": "MARYVILLE",
"_state": "TN",
"_zip": "37804"
},
{
"_address1": "Last Reported Address - Out of State",
"_city": "LOUISVILLE",
"_state": "TN",
"_zip": "37777"
}
]
}
}
},
"identification": {
"ipAddress": "XXXXXXXX",
"applicationID": "XXXX"
}
}
I would recommend recording the request which is successful using JMeter's HTTP(S) Test Script Recorder and once you have a working request which you can successfully replay you can correlate dynamic and parameterize user-specific values.
Upvotes: 1