簡體   English   中英

有沒有辦法用jmeter beanshell預處理器動態設置post請求的變量值

[英]Is there a way to dynamically set variables values for the post request with jmeter beanshell preprocessor

我需要使用jmeter beanshell預處理器動態構建以下post請求JSON主體。 我指的是以下問題 ,它解決了我的循環字符串問題。 我需要用json-property(變量)來做一個具有不同名稱和值的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"
    }
  ]
}

使用帶有參數化json請求的虛擬采樣器和用於動態輸入的CSV數據集配置。 下面,我只有兩個用於演示。

在此輸入圖像描述 在此輸入圖像描述

然后,使用JSR223 Post處理器,代碼如下: -

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

這將把響應體放在“responseVar”變量中。 使用$ {responseVar}獲取它

希望這可以幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM