如何将多个regexpression提取的值传递给单个http请求?

时间:2017-06-03 10:55:39

标签: regex jmeter

我向服务器发送第一个请求: POST http://192.168.7.101/r2.web/Planning/Scheduling/TimelinefromR3 - > (A)

我编写了正则表达式提取器((?<=\"Values":")(.*?)(?=\"))来从(A)的响应中提取“Ray Gwilliams”和“James Mark”等资源名称,

现在,我有另一个请求(如下所述),我需要传递上面提取的所有资源名称(“Ray Gwilliams”和“James Mark”)。

  

请告诉我如何实现这一目标。

http://192.168.7.101/R2.Web/Planning/Scheduling/SchedulesAndGroups

POST数据: [{“ColumnName”:“CONTACTNAME”,“ColumnIId”:0,“UdfIId”:null,“ConditionIId”:0,“OperatorIId”:1,“SequenceNo”:0,“Values”:“ Ray Gwilliams ”, “查找”:NULL, “LookupIId”:0 “LookupSource”:0 “LookupType”:0 “MultipleOperatorIIds”:NULL, “MultipleValues”:NULL, “ColumnDataType”:空},{ “的ColumnName”: “CONTACTNAME”,“ColumnIId”:0,“UdfIId”:null,“ConditionIId”:0,“OperatorIId”:1,“SequenceNo”:0,“值”:“ James Mark ”, “查找”:NULL, “LookupIId”:0 “LookupSource”:0 “LookupType”:0 “MultipleOperatorIIds”:NULL, “MultipleValues”:NULL, “ColumnDataType”:空}

1 个答案:

答案 0 :(得分:0)

我没有使用正则表达式但是如果你使用JSON Extractor元素并将提取的值放入变量中,你只需将变量添加到第二个POST请求中。例如:

POST data:     
[{"ColumnName":"CONTACTNAME",
"ColumnIId":0,"UdfIId":null,"ConditionIId":0,
"OperatorIId":1,"SequenceNo":0,
"Values":"${variable1} ","Lookup":null,"LookupIId":0,
"LookupSource":0,"LookupType":0,
"MultipleOperatorIIds":null,"MultipleValues":null,
"ColumnDataType":null},  {"ColumnName":"CONTACTNAME",
"ColumnIId":0,"UdfIId":null,
"ConditionIId":0,"OperatorIId":1,
"SequenceNo":0,
"Values":"${variable2} ","Lookup":null,"LookupIId":0,
"LookupSource":0,"LookupType":0,
"MultipleOperatorIIds":null,
"MultipleValues":null,"ColumnDataType":null}

提示:要获取要提取的值,请在树中侦听元素或此助手工具中使用jmeter的JSON路径测试器:http://jsonpath.com/