Iām new to Postman and do not have any coding experience. How would I go about creating assertions to verify values for ānameā, ālatitudeā, āupperLimitā and ālowerLimitā in the code below?
What kind of assertions do you need? To verify that the values are exactly that? Or do you need to verify just that the fields exist and are of a specific data type?
The simplest form is matching the exact values you have, but it wonāt work with other responses (since the values will likely change)
Using pm.expect this way will verify that your response has the specific properties with the passed in values.
There are ways you can make this dynamic and richer as time goes on, like parameterizing the variable values, or validating the response against a schema. But just give it time for you to understand the pieces and how everything fits together.
Thank you, Allen for the response. However, I am encountering the error shown below when running the assertion. Any further help you can provide would be appreciated.
FAIL
Has correct values | AssertionError: expected { Object (@type, id, ā¦) } to have property āupperLimitā
@Straub2148 is this a public facing API that we can use or an internal project? if itās public facing can we get the URL and the relevant GET/POST information please?
The error for the second case is less clear than in the first, if the property is missing.
In the first case, it will tell you the property canāt be found.
In the latter case, it will tell you that undef does not equal 250.0
But basically, yah, you need to add the complete json node path.
To help you in the future for working with json, if youāre trying to get to a specific value, you need to add a dot every time you see a curly brace ā{ā