jmeter-如何使用从另一个请求的主体数据中的响应中提取的值 [英] jmeter - how to use extracted value from response in Body Data of another request

查看:1274
本文介绍了jmeter-如何使用从另一个请求的主体数据中的响应中提取的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在另一个请求的正文数据"中使用提取的值.我使用如下所示的JSON Path Extractor提取了值

I'm trying to use the extracted value in Body Data of another request. I extracted the value using JSON Path Extractor like below

值是从以下响应中提取的

value is extracted from the below response

我在Body数据中这样使用它

I used it like this in Body data

  {
    "TransactionId": ${transactionId},
    "Cancelled": false
  }

但这在 JMeter 中不起作用,它显示transactionId为["223"]. 我希望只有223

but this is not working in JMeter it shows the transactionId as ["223"]. I want it to be only 223

推荐答案

我们可以通过不同的方式来做到这一点,但是我更喜欢使用"Jmeter"功能(最好避免使用插件). 对于源git 链接

We can do this in different ways, but I prefer to use "Jmeter" functionality (better to avoid plugins). For source git link

1. Using "Regular Expression Extractor" post processor.
2. Using "JSON Path PostProcessor" post processor.

  1. 正则表达式提取器":正则表达式提取器不是最好的功能.

  1. "Regular Expression Extractor": Regular Expression Extractor is no of the best functionality.

Regular Expression: "transactionId":"(.+?)" Template: $1$ Match Number: 1

Regular Expression: "transactionId":"(.+?)" Template: $1$ Match Number: 1

2."JSON Path PostProcessor":我从没使用过此后处理器,它也很好.下面是表达式

2."JSON Path PostProcessor": I never used this post processor, it's also good. Below is the expression

JSON path Expression : $.transactionId Match Numbers: 1

JSON path Expression : $.transactionId Match Numbers: 1

请在查看结果树"中的Debugger Sampler中找到结果

Please find the Results in Debugger Sampler, in "view Results tree"

这篇关于jmeter-如何使用从另一个请求的主体数据中的响应中提取的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆