How can I get the sub-nodes EntityPropertyValue
,ProductPropertyValueUId
,ProductPropertyValueDisplayName
that come under the parent node ["Name": "PriorityUId"]
using Rest Assured ?
Below is the code snippet
RequestSpecification request = RestAssured.given();
request.header("Content-Type", "application/json");
JSONObject requestParams = new JSONObject();
requestParams.put("data", "somedata");
request.body(requestParams.toJSONString());
Response response = request.post("url");
List<Map<String, String>> epv = response.jsonPath().getList("EntityPropertyValues");
for(int i=0;i<epv.size();i++)
{
if(epv.get(i).containsValue("PriorityUId"))
{
System.out.println(epv.get(i));
break;
}
}
I am doing a sysout and I get the entire below block of data in response.
{
"Name": "PriorityUId",
"Values": [
{
"EntityPropertyValue": "Critical",
"ProductPropertyValueUId": "00000019-0000-0000-0000-000000000033",
"ProductPropertyValueDisplayName": "Blocker"
},
{
"EntityPropertyValue": "Critical",
"ProductPropertyValueUId": "00000019-0000-0000-0000-000000000034",
"ProductPropertyValueDisplayName": "Critical"
},
{
"EntityPropertyValue": "High",
"ProductPropertyValueUId": "00000019-0000-0000-0000-000000000035",
"ProductPropertyValueDisplayName": "Major"
}
],
"DataTypeUId": "00100002-0007-0000-0000-000000000000",
"DisplayName": "Priority"
}
How can I capture the fields I am looking for?
Below is the entire JSON response
{
"ProductInstance": "00000000-0000-0000-0000-000000000000",
"DataTypeUId": null,
"EntityPropertyValues": [
{
"Name": "ModifiedAtSourceByUser",
"Values": [],
"IsPropertyExists": true
},
{
"Name": "ModifiedAtSourceOn",
"Values": []
},
{
"Name": "PriorityUId",
"Values": [
{
"EntityPropertyValue": "Critical",
"ProductPropertyValueUId": "00000019-0000-0000-0000-000000000033",
"ProductPropertyValueDisplayName": "Blocker"
},
{
"EntityPropertyValue": "Critical",
"ProductPropertyValueUId": "00000019-0000-0000-0000-000000000034",
"ProductPropertyValueDisplayName": "Critical"
},
{
"EntityPropertyValue": "High",
"ProductPropertyValueUId": "00000019-0000-0000-0000-000000000035",
"ProductPropertyValueDisplayName": "Major"
}
],
"DataTypeUId": "00100002-0007-0000-0000-000000000000",
"DisplayName": "Priority"
}
]
}