设置授权api的标头 [英] Set the headers for authorization api
问题描述
我正在将标头从登录API的响应传递到下一个授权的API.
I am passing the headers from the response of login API to the next authorized API.
测试计划结构:
我必须在标头中传递SRToken,Id1,Id2和Id3,因此,我为所有这些标头添加了JSON提取器,并为其设置了值.下面的屏幕截图显示了我如何提取值.例子
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
通过这种方式,我从Id1,Id2和Id3提取了值. 然后我已经使用Debug Sampler来查看存储的值了吗? 但是我在这里没有得到价值.
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
推荐答案
您需要根据响应头"字段进行提取.使用正则表达式提取器作为Login Sampler的子项[需要从其响应中提取这些字段].示例正则表达式显示在我提取数字的位置[如果要提取单词,请将正则表达式更改为(\ w +).或任何正则表达式都可以使用].
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"
这篇关于设置授权api的标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!