0

i use JMeter for REST API testing and i have following request in my POST data section:

{
  "RootUrl": "http://localhost:4747",
  "Name": "E-commerce website",
  "ContentSite": true,
  "ContentLinks": [
    {
      "RegexPattern": "(log|sign)\\-?(out|off)"
    }
   ]
}

it is working regularly.

i'd like to use RootUrl as parameter so i created a "User Defined Variables". enter image description here

{
  "RootUrl": "${website_url}",
  "Name": "E-commerce website",
  "ContentSite": true,
  "ContentLinks": [
    {
      "RegexPattern": "(log|sign)\\-?(out|off)"
    }
   ]
}

When run it, it gives Request is NOT valid error. When i check it in Result tree, "RegexPattern" looks changed. There is one reverse slash in entity:

"RegexPattern": "(log|sign)-?(out|off)"

Do you have any idea why parameter does change another part?

Thanks in advance

Mahsum Akbas
  • 1,523
  • 3
  • 21
  • 38
  • Do not escape `-` at all. Use `"(log|sign)-?(out|off)"`. Outside a character class, it is a regular, literal `-` char. – Wiktor Stribiżew Apr 30 '18 at 08:16
  • @WiktorStribiżew it is interest, when i don't use parameters, it works. what does parameter trigger in regex? why gives error when use parameters? – Mahsum Akbas Apr 30 '18 at 08:41
  • That is probably a JMeter feature, since you might define UD functions in there, right? A ``\`` is an auxiliary symbol there that is used to escape `,` and `$`, so probably that is why it just got removed. – Wiktor Stribiżew Apr 30 '18 at 09:24

0 Answers0