| Andrey Pohilko Chief Scientist P: +7 (909) 631-21-69 |
![]() |
| Andrey Pohilko Chief Scientist P: +7 (909) 631-21-69 |
![]() |
--
You received this message because you are subscribed to the Google Groups "codename-taurus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codename-taur...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/codename-taurus/08243851-5641-4e43-b5fe-491270fb2bc9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
scenarios:
scenario1:
requests:
- url:
extract-jsonpath:
userToken: $.access_token
jsr223: 'vars.put("tokenVar", ${userToken})’.
[[ Note: Also tried as below ..
jsr223:
execute: after
script-text: |
vars.put("tokenVar", ${userToken}) ]]
scenario2:
requests:
- url:
headers:
Authorization: Bearer ${__base64Encode(${tokenVar})}
[ [ Note: Also tried to access
Authorization: Bearer ${__base64Encode(${vars.get("tokenVar")})}
I believe I dont have to add jsr223 block to retrieve (access) the value ..
]]
Getting error jmeter.log as below:
2023-10-20 10:37:41,555 ERROR o.a.j.e.JSR223PostProcessor: Problem in JSR223 script, JSR223PostProcessor
javax.script.ScriptException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script1.groovy: 1: Unexpected input: '(' @ line 1, column 9.
vars.put("tokenVar", fa6-ba1-4ff-a29-5d782)
^
1 error
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.compile(GroovyScriptEngineImpl.java:183) ~[groovy-jsr223-3.0.7.jar:3.0.7]
As I cannot use put (due to above error), I coudnt write to file using solution provided above-- > new File('file.txt').text = vars.get('your-variable-name')
Thanks for the hint, this is a bad idea, but still I tried a temporary alternative as below:
In scenario1:
jsr223:
execute: after
script-text: |
new File('file.txt').text = '${userToken}' # works fine
In scenario2:
variables:
userTokenNew: no # declared a new local variable
jsr223:
execute: before
script-text: |
userTokenNew = new File('file.txt').text. # works fine
headers:
Authorization: Bearer ${__base64Encode('${userTokenNew}')}. # Unauthorized error