简体   繁体   中英

How to pass dynamic headers to the Http Request in jMeter?

There is a initial request going to the server which should retrieve the CSRF token and use that token id in post request header.

if that does not happen any POST requests to the server will return that error.

在此处输入图片说明

In the above screen shot, where token is the request to get the CSRF token Id, If I run the test this will generate one dynamic random token ID. But I need to pass the generated token ID in the post request through Header Manager. How can it possible. If yes, Can any one suggest some way to do that.

我通过使用用户定义的变量和正则表达式提取器将参数从一个请求采样器传递到另一个来解决它。

In the firs request add a postprocesor of the request. if the response is un json format user json Extractor, in json Extractor define a variable that read the token

In the second request add a header Manager an refer varaible declare in json Extractor in the following way in value cell, ${variable}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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