The following paste contains data returned by our API.
{
"result": "OK",
"sysStatisticsReport": null,
"sysStatisticsData": {
"sysDataStatisticsList": [{
"RLibID":"x400410000",
"sysDataDetails": []
}, {
"RLibID":"x872690000",
"sysDataDetails": []
}, {
"RLibID":"x871710000",
"sysDataDetails": []
}, {
"RLibID":"x800070000",
"sysDataDetails": [{
"sysvRequestId": 2811,
"sysRequestDataStatistics": {
"requestingRLibID":"x800070000",
"requestingItsRequestId": "706742005###CG",
"availabilityRequestedAt": "2020-06-22 06:51:58",
"recordIdentifierType": "PPN",
"recordIdentifierCode": "321528360"
},
"sysReservedDataStatistics": [{
"requestingRLibID":"x800070000",
"requestingItsRequestId": "706742005###CG",
"ilsReservedAt": "2020-06-22 06:52:00",
"recordIdentifierType": "PPN",
"recordIdentifierCode": "321528360",
"xCodeWhereReserved": "x870410000",
"levelType": "COUNTRY",
"ilsCancelledMessage": "BY_TIMEOUT",
"reservationCancellationMessage": "BY_TIMEOUT",
"cancelledByReservedIts": false,
"cancelledBySYSVEngine": false,
"timeOutBySYSV": true
}, {
"requestingRLibID":"x800070000",
"requestingItsRequestId": "706742005###CG",
"ilsReservedAt": "2020-06-22 06:52:00",
"recordIdentifierType": "PPN",
"recordIdentifierCode": "321528360",
"xCodeWhereReserved": "x834240000",
"levelType": "COUNTRY",
"ilsCancelledMessage": "BY_TIMEOUT",
"reservationCancellationMessage": "BY_TIMEOUT",
"cancelledByReservedIts": false,
"cancelledBySYSVEngine": false,
"timeOutBySYSV": true
}, {
"requestingRLibID":"x800070000",
"requestingItsRequestId": "706742005###CG",
"ilsReservedAt": "2020-06-22 06:52:00",
"recordIdentifierType": "PPN",
"recordIdentifierCode": "321528360",
"xCodeWhereReserved": "x870290000",
"levelType": "COUNTRY",
"ilsCancelledMessage": "BY_TIMEOUT",
"reservationCancellationMessage": "BY_TIMEOUT",
"cancelledByReservedIts": false,
"cancelledBySYSVEngine": false,
"timeOutBySYSV": true
}],
"sysShippedDataStatistics": []
}]
}],
"problem": null
}
}
The first assertion I’m running is to see if a unique ID (contains ###CG) can be found like so (uid should be found in sysRequestDataStatistics. then, uid should be found in sysReservedDataStatistics, etc):
pm.test("Get Stats", function () {
var jsonData = pm.response.json();
pm.expect(jsonData.
sysStatisticsData.
sysDataStatisticsList.
sysDataDetails.
sysRequestDataStatistics.
requestingItsRequestId.
value).
to.eql(pm.collectionVariables.get("uID"));
});
However, the assertion fails at the detection of the first existing sysDataDetails being an empty array.
TypeError: Cannot read property ‘sysRequestDataStatistics’ of undefined
How should I create the correction assertion?