I want to get value of “@id” for “hardwareId”: “-1517125410” and using the value of “@id” get the expiration date where “hardwareId” == “@id”
For e.g.: For “hardwareId”: “-1517125410”, value of “@id”: “2432ef7a-ada4-4357-812d-6b0bbe90ed6f”
And in licenses array , “hardwareId”: “2432ef7a-ada4-4357-812d-6b0bbe90ed6f”
get the value of “expirationDate”: “2023-05-16T23:59:59.027+00:00”
Request: GET
Code:
{
"hardwareIds": [
{
"@id": "2432ef7a-ada4-4357-812d-6b0bbe90ed6f",
"id": 32206,
"hardwareIdString": "-1517125410",
"details": null,
"hardwareId": "-1517125410"
}
],
"licenses": [
{
"@id": "42010c27-a075",
"id": 34454,
"hardwareId": "2432ef7a-ada4-4357-812d-6b0bbe90ed6f",
"user": "e4771618-9f1d-402c-b924",
"expirationDate": "2023-05-16T23:59:59.027+00:00",
"maintenanceDate": "2023-05-16T23:59:59.027+00:00",
"enabled": true,
"productProfile": "fdd4536d-fb5f",
"profileRole": "2c79ef63-bd3c-",
"createdDate": "2023-03-09T06:14:32.560+00:00",
"modifiedDate": "2023-03-17T08:55:17.137+00:00"
},
{
"@id": "baa20043-49e0-41a3-9256-68c2adff1ad5",
"id": 34453,
"hardwareId": "2432ef7a-ada4-4357-812d-6b0bbe90ed6f",
"user": "e4771618-9f1d",
"expirationDate": "2023-05-16T23:59:59.027+00:00",
"maintenanceDate": "2023-05-16T23:59:59.027+00:00",
"enabled": true,
"productProfile": "490a57be-0904",
"profileRole": "3da6da45-fed5",
"createdDate": "2023-03-09T06:14:32.560+00:00",
"modifiedDate": "2023-03-17T08:55:17.137+00:00"
},
{
"@id": "d5331ddb-9f90-445f-9e86-8a7d87d3857f",
"id": 34247,
"hardwareId": "6ae5010e-1c27-4869-8679-be99ba3ced92",
"user": "e4771618-9f1d-402c",
"expirationDate": "2023-01-24T23:59:59.237+00:00",
"maintenanceDate": "2023-01-24T23:59:59.237+00:00",
"enabled": true,
"productProfile": "fdd4536d-fb5f",
"profileRole": "2c79ef63-bd3c",
"createdDate": "2022-11-25T07:30:44.517+00:00",
"modifiedDate": "2023-03-17T08:55:17.137+00:00"
},
{
"@id": "baa20043-49e0-41a3",
"id": 34453,
"hardwareId": "2432ef7a-ada4-4357-812d-6b0bbe90ed6f",
"user": "e4771618-9f1d",
"expirationDate": "2023-05-16T23:59:59.027+00:00",
"maintenanceDate": "2023-05-16T23:59:59.027+00:00",
"enabled": true,
"productProfile": "490a57be-0904-43ff-adaf-",
"profileRole": "3da6da45-fed5-4c36-b7d7-",
"createdDate": "2023-03-09T06:14:32.560+00:00",
"modifiedDate": "2023-03-17T08:55:17.137+00:00"
}
],
"enabled": true,
"deliveryNote": null
}
I have used below logic
.check(jsonPath(s"$$.hardwareIds[?(@.hardwareId == '${hardwareId}')].${x}").saveAs("hardwareIdObj"))
.check(jsonPath(s"$$.licenses[?(@.hardwareId == '${hardwareIdObj}')].expirationDate").saveAs("hardwareIdObj"))