Set the headers for authorization api

只愿长相守 提交于 2019-12-11 15:25:50

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!