问题
I am passing the headers from the response of login API to the next authorized API.
Test plan structure:
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
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.
I have also tried using Regular Expression Extractor
回答1:
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"
回答2:
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
来源:https://stackoverflow.com/questions/57370152/set-the-headers-for-authorization-api