【问题标题】:Is there a way to dynamically set variables values for the post request with jmeter beanshell preprocessor有没有办法使用 jmeter beanshell 预处理器为发布请求动态设置变量值
【发布时间】:2019-05-27 04:58:11
【问题描述】:

我需要使用 jmeter beanshell 预处理器动态构建以下 post 请求 JSON 正文。我指的是以下question,它可以解决我的循环字符串问题。我需要使用 json-property(variables) 一组具有不同名称和值的 JSON 对象来执行此操作。非常感谢。

{
  "processDefinitionId":"optaplannerkey:1:dbc4af8f-7e04-11e9-afa3-1ecac26bb5e0",
  "businessKey":"optaplannerkey",
  "returnVariables":true,
  "variables": [
    {
      "name": "TaskDescription",
      "value": "Fixing the issue with sink"
    },
    {
      "name": "TaskCategory",
      "value": "plumbing"
    },
    {
      "name": "Priority",
      "value": "Medium"
    },
    {
      "name": "Status",
      "value": "New"
    },
    {
      "name": "SkillsRequired",
      "value": "Plumbing Skills"
    },
    {
      "name": "DueDate",
      "value": "2019-05-24T11:23:08.030+05:30"
    }
  ]
}

【问题讨论】:

    标签: java jmeter beanshell flowable


    【解决方案1】:

    将虚拟采样器与参数化的 json 请求和 CSV 数据集配置一起用于动态输入。下面,我只为演示参数化了两个。

    然后,使用带有以下代码的 JSR223 后处理器:-

    vars.put("responseVar",prev.getResponseDataAsString());
    

    这会将响应正文放入“responseVar”变量中。使用 ${responseVar}

    获取它

    希望这会有所帮助。

    【讨论】:

    • 非常感谢@sunny-teo 我确实解决了您使用 CSV 数据集的方法的问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多