Set the headers for authorization api

2019-08-30 22:32发布

I am passing the headers from the response of login API to the next authorized API.

Test plan structure: enter image description here

I have to pass the SRToken, Id1, Id2, and Id3 in the header so, I have added JSON extractor for all these headers and set the values fro them. Below screenshot shows how I have extracted values. Example enter image description here

In this way I have extracted values fro Id1, Id2 and Id3. Then I have used Debug Sampler to view the values are stored? But I am not getting the values here. enter image description here

I have also tried using Regular Expression Extractor enter image description here

2条回答
Deceive 欺骗
2楼-- · 2019-08-30 22:43

JSON is irrelevant in Headers,

You should use Regular Expression Extractor with Field to check set Request Headers and use regular expression for getting the needed values

查看更多
一夜七次
3楼-- · 2019-08-30 22:59

You need to extract based on Response Header field. Use Regular Expression extractor as a child of your Login Sampler [from whose response these fields need to be extracted]. Sample Regular Expression is shown where I am extracting digit [change Regular Expression to (\w+) if you want to extract words. or any regex will work].

Most important here is to select "Field to check as Response Headers"

enter image description here

查看更多
登录 后发表回答