Anusha
Anusha

Reputation: 11

Jmeter error due to captured token containing '\x'

In my testing scenario most of the responses fail due to the captured token having a \x in it. The token without this \x does pass. How should I handle this token or what is required to be converted here. I did try urlencode , urldecode

token for example - 00ceR2t8n\x2DfSp6lfvPvm_xxB23683omTcxbE\x2DulsTf

Upvotes: 1

Views: 199

Answers (3)

Anusha
Anusha

Reputation: 11

Probably my question was not constructed the right way.

The below solution worked for me -

added a beanshell postprocessor with the below code

${__javaScript("${stateToken}".split('\x2D').join('-'),FOO)} the converted variabled was stored in Foo.

and substituted ${Foo} in the the required place.

Upvotes: 0

Dmitri T
Dmitri T

Reputation: 168122

If you really need to remove these \x signs the best option is going for __strReplace() function like:

${__strReplace(${token},\\\x,,)}

Demo:

enter image description here

__strReplace() function can be installed as a part of Custom JMeter Functions bundle using JMeter Plugins Manager

Upvotes: 2

Gökhan Uçar
Gökhan Uçar

Reputation: 226

Create a JSR 223 post processor and write the code below:

def responseToken = vars.get("token")
def newToken = responseToken.replace("\\x", "")
vars.put("newToken", newToken)

Then use this newToken variable

Upvotes: 0

Related Questions