https://linen.dev logo
#help
Title
m

Mani Kasi

08/05/2023, 11:16 AM
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

Lee Turner

08/05/2023, 9:10 PM
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

Mani Kasi

08/06/2023, 2:23 AM
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

Lee Turner

08/06/2023, 10:03 AM
Awesome. Glad you got it sorted.
🤝 1
m

Mani Kasi

08/09/2023, 6:50 AM
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

Lee Turner

08/09/2023, 7:52 AM
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