gpt4 book ai didi

http - 在 Jmeter http 请求中使用 vars.get 而不是 '$'

转载 作者:可可西里 更新时间:2023-11-01 16:59:38 27 4
gpt4 key购买 nike

我有一个关于在 Jmeter 中使用 http 请求的问题我创建了一个 json 请求。我尝试传递我在前面步骤中使用的参数(我使用 vars.put("Expected_Offer_Name") 保存它)。
我想使用 vars.get("Expected_Offer_Name") 作为参数,但 Jmeter 拒绝使用此参数。

但是当我使用“${Expected_Offer_Name}”时它工作正常。1.有什么区别?在这两种情况下,我都想传递一个字符串参数。2. 他们是使用 vars,get 的一种方式吗?

[ Not working ][不工作]

[ enter image description here ][工作]

他们是在 json 的 http 请求中使用 vars.get 的方法吗

最佳答案

您不能在 HTTP 请求中使用变量。

vars 是仅用于脚本的特殊变量,仅在以下情况下可用:

  1. JSR223 Elements脚本

Before invoking the script, some variables are set up. Note that these are JSR223 variables - i.e. they can be used directly in the script.

  1. Beanshell/groovy 元素或函数。

它还被添加用于使用 right way 获取变量:

ensure the script does not use any variable using ${varName} as caching would take only first value of ${varName}. Instead use : vars.get("varName")

在其他地方你需要使用${varName}获取变量

关于http - 在 Jmeter http 请求中使用 vars.get 而不是 '$',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49840153/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com