ohaya wrote:
Hi,
I am working on a test plan where I send a POST request to authenticate, and I
get a token in the response.
Then, I need to send the token in GET request to get authorized.
The problem I am having is that the the response I am getting to the POST has
the token surrounded by double-quotes (a double-quote in the front, and a
double-quote, or possibly a double-quote followed by a blank/space) and I think
that the double-quotes are causing the error.
I am extracting the token in a JSR233 Postprocessor with the following script:
vars.put("response", prev.getResponseDataAsString());Can I remove the leading
double-quote and the trailing double-quote (or possibly trailing double-quote+space in
the same Postprocessor, and if so how can I do that?
Thanks,Jim
If you want to do this in Groovy - amend your code like:
vars.put('response',
prev.getResponseDataAsString().replaceAll(/^['"\s]+|['"\s]+$/, ''))
or just
vars.put('response', prev.getResponseDataAsString().takeBetween('"'))
Check out Groovy SDK documentation on String class
<https://docs.groovy-lang.org/latest/html/groovy-jdk/java/lang/String.html>
and The Groovy Templates Cheat Sheet for JMeter
<https://www.blazemeter.com/blog/groovy-templates> article for more
useful code examples
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@jmeter.apache.org
For additional commands, e-mail: user-h...@jmeter.apache.org