vendredi 25 janvier 2019

How do i identify an iteration of an array in a Postman response using pm.expect to validate a value?

I have a standard array JSON response being returned like this:

{
    "data": [
        {
            "ïd": 1000,
            "name": "First Object"
        },
        {
            "ïd": 1001,
            "name": "Second Object"
        }
    ]
}

I am trying to validate the second id in the array using:

pm.expect(jsonData.data.id[1]).to.eql("1001");

However, it does not. In the Java RESTAssured test framework I used to use, this was the very easy way to identify which like-named object in the array that you were validating. I am unsure how to do this in Postman. Can anyone help please? Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire