简体   繁体   English

如何将在JSON路径提取器中提取的变量用于场景的进一步步骤?

[英]How to use variable extracted in JSON path extractor for further steps of scenario?

I have created one scenario in Jmeter where i am loging in. (For this scenario i am using REST APIs) For this i took one "HTTP Header Manager" , "HTTP Request Sampler". 我已经在Jmeter中创建了一个要登录的场景。(对于该场景,我正在使用REST API)为此,我选择了一个“ HTTP Header Manager”,“ HTTP Request Sampler”。

After login i am extracting authentication token which is generated automatically. 登录后,我正在提取自动生成的身份验证令牌。 Using this auth token i am trying to add some values in application. 使用此身份验证令牌,我试图在应用程序中添加一些值。 For this i used: 1) jp@gc - JSON Path Extractor 2) Debug Sampler 为此,我使用了:1)jp @ gc-JSON路径提取器2)调试采样器

On execution, i can see auth token capture in "View Results Tree" listner. 执行后,我可以在“查看结果树”列表器中看到身份验证令牌捕获。

But adding user (second HTTP Request sampler) steps fails saying error "unauthorized. 但是添加用户(第二个HTTP请求采样器)步骤失败,提示错误“未授权”。

Can you please tell me how to use that auth token in "Add User" step so that i can update web application. 您能告诉我如何在“添加用户”步骤中使用该身份验证令牌,以便我可以更新Web应用程序。

JSON提取器

The JSON extractor values have to be filled like mentioned in the sample (image) above. JSON提取器值必须像上面的示例(图像)中所述那样进行填充。

Pass the variable as ${jsonVal} to second HTTP Request sampler as value to parameter for authentication token either in the HTTP request or the HTTP Header data (wherever applicable). 将变量$ {jsonVal}传递给第二个HTTP Request采样器,作为HTTP请求或HTTP Header数据中(如果适用) 身份验证令牌参数的值。

Hope this will help. 希望这会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM