Jmeter - getting 401 unauthorized error after login



  • I have to record a large test plan including 4 transactional controllers and response assertions for the UI side but at the time of login there is token generated and I am doing correlation manually.

    I have used the regular expression extractor to extract the token from my login response but it gives the following error:

    org.apache.oro.text.MalformedCachePatternException: Invalid expression: (?<=("|')token("|'):("|'))(.*?)("|')(=?) Sequence (?<...) not recognized.
    

    Please guide me also how can testplanI pass this TOKEN on the further request as each request has its own header manager. How I can pass THIS TOKEN OVER 4 TRANSACTIONAL CONTROLLER. I am adding my test plan for reference. Please guide me on a suitable process to do this.



  • The exception clearly states that Sequence (? not recognized

    As per jmeter documentation https://jmeter.apache.org/usermanual/regular_expressions.html, Lookbehind expression (?

    enter image description here

    So use:

    ("|')token("|'):("|')(.*?)("|')
    

    Here we have 5 groups, the actual token is in the 4th group and to get just the token value set template field as: $4$

    enter image description here



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2