0

I am trying to write regular expression in JMeter regular extractor for CSRF Token:

CSRF Token: P_rF1DbLR4JWcBtxEwGKKw==

and Expression I am using is:

name : CSRF_Token_Retrieved_Value
regular expression: x-csrf-token:\s+(.+)
template : $1$

I get this error

CSRF token validation failed

in next steps.

Peyman Mohamadpour
  • 17,954
  • 24
  • 89
  • 100
  • 1
    May be you can try checking the regular expression used from the previous response using the View Result Tree > [Regular expression tester](https://jmeter.apache.org/usermanual/component_reference.html#View_Results_Tree). – Raj May 19 '20 at 05:16

1 Answers1

0

Your regular expression doesn't match the value you provided, you need to change it to:

CSRF Token:\s+(.+)

Demo:

enter image description here

Also if the token comes in one of the HTTP response headers you need to switch the Regular Expression Extractor to look into Response Headers:

enter image description here

More information: How to Load Test CSRF-Protected Web Sites

Dmitri T
  • 159,985
  • 5
  • 83
  • 133