Reputation: 55
I was trying to match particular variable from response and tried as below. But im getting error saying KarateException Missing Property in path $['Odata']
. My question is: how we can modify so that we won't get this error?
Feature:
And match [email protected] contains '<b>'
Examples:
|b|
|b1 |
|b2 |
Response is
{
"@odata.context": "$metadata#Accounts",
"a": [
{
"c": 145729,
"b": "b1",
"d": "ON",
},
{
"c": 145729,
"b": "b2",
"d": "ON",
}
]
}
Upvotes: 1
Views: 2107
Reputation: 58058
I think you are confused with the structure of your JSON. Also note that when the JSON key has special characters, you need to change the way you use them in path expressions. You can try paste the below in a new Scenario and see it work:
* def response =
"""
{
"@odata.context": "$metadata#Accounts",
"a": [
{
"c": 145729,
"b": "b1",
"d": "ON",
},
{
"c": 145729,
"b": "b2",
"d": "ON",
}
]
}
"""
* match response['@odata.context'] == '$metadata#Accounts'
* match response.a[0].b == 'b1'
* match response.a[1].b == 'b2'
Upvotes: 1