Can someone help me on the `xml` request matching ...
# help
m
Can someone help me on the
xml
request matching with XPath/XUnit? _Request Body_:
<person_obj id= \"1\">
<params id= \"2\">
<name id= \"3\">Mani Kasi</name>
</params>
</person_obj>
Matching Conditions: name contains with 'Mani' or 'Jack' or 'Mike'
i.e., Please correct me here
"bodyPatterns": [
{
"ignoreArrayOrder" : true,
"ignoreExtraElements" : true,
"matchesXPath":{
"expression": "//person_obj/params/name/text()",
"or": [
{"contains": "Mani"}, {"contains": "Mike"}, {"contains": "Jack"}
]
}
}
]
l
Not sure what the problem is there. I have tested this locally and this seems to work:
Copy code
{
  "request": {
    "urlPath": "/xml-test",
    "method": "ANY",
    "bodyPatterns": [
      {
        "ignoreArrayOrder": true,
        "ignoreExtraElements": true,
        "matchesXPath": {
          "expression": "//person_obj/params/name/text()",
          "or": [
            {
              "contains": "Mani"
            },
            {
              "contains": "Mike"
            },
            {
              "contains": "Jack"
            }
          ]
        }
      }
    ]
  },
  "response": {
    "status": 200
  }
}
đź‘Ť 1
This was tested with your request body:
Copy code
<person_obj id="1">
    <params id="2">
        <name id="3">Mani Kasi</name>
    </params>
</person_obj>
Could you can add any further information that might help figure out what is wrong ?
m
yes, It's worked.
The issue is due to escape char in my request body.
<person_obj id=\"1\">
<params id=\"2\">
<name id=\"3\">Mani Kasi<\name>
<\params>
<\person_obj>
l
Awesome. Glad you got it sorted.
🤝 1
m
Hi @Lee Turner / Team, Do you any idea how can we use the "notEqual" (negate use case) matching condition with request body? i.e.,
"matchesJsonPath": {
"expression":"$.names[0].first_name",
"and":[
{"notEqualTo":"David"},
{"notEqualTo":"Jack"},
{"notEqualTo":"Mike"}
]
}
l
Hi, Looking at the code I couldn’t see a
notEqualsTo
. I haven’t tried these but maybe
doesNotContain
or
doesNotMatch
(regex) might help here ?
tq 1