Yvonne
Yvonne

Reputation: 33

JMeter, authenticity token has been encoded, how to decode

My script get an authenticity token from first page, then pass it to the second page I got this error when running the test:

{"errors":{"error:":["ActionController::InvalidAuthenticityToken"]}}

I checked the token variable, apparently the string such as /, = has been encoded into %2F and %3D etc..

On my second page's HTTP request window, I have NOT selected "encoded" for token variable defined in the "Send parameters with the request" section.

Apparently the problem is I did not asked for encoded variable, JMeter just encode it. Is it a known bug or I should do something to decode it or is there a work around on this issue?

Upvotes: 0

Views: 1026

Answers (1)

F2nd
F2nd

Reputation: 384

Did you pass token in POST data?

I'v faced the same problem and just pass body data as work around, to do it you need:

  1. Select you HTTP sampler
  2. Switch from "Parameter" to "Body Data" tab (you have to delete all parameters to do it)
  3. Write body data (variable substitution works)

Body data example:

username=Some_name&token=AbRaCaDaBrA

NB, if something need to be encoded, you'll have to do it manually.

Upvotes: 1

Related Questions