0

I am new to API's and postman and I was trying to test some REST APIs for my organization using postman. My question is regarding response header.

As when I hit request for my user to get authorization key, I get that key in my response header like set-Authentication -> key. I am using this key to invoke authorized requests. Now I have apply this key manually everytime. Is there any way where I can fetch this key from response header by pre-request script so that it hit's authorization request everytime -> get token and use it for authentication key.

I will really appreciate any help. Thank you :)

  • check out https://stackoverflow.com/questions/40539609/how-to-add-authorization-header-in-postman-environment – Jay Ganesan Jan 30 '19 at 21:50
  • Take a look here: https://www.yukei.net/2016/01/getting-response-headers-data-from-an-ajax-request-with-jquery/ – ZorgoZ Jan 30 '19 at 21:52
  • You should consider looking to [pre-request scripts](https://learning.getpostman.com/docs/postman/scripts/pre_request_scripts/). You can make calls to get a token for example then set the value of a collection/environment/global variable that can be used effectively anywhere, including a collection or requests authorization tab. – Alexander Staroselsky Jan 30 '19 at 22:05
  • @JayGanesan I did check that out but it doesn't give any light on how can I automate it. I still have to add header in each and every request. I want to get it updated by it self if token is expired and apply it again. – newbiverification Jan 30 '19 at 22:06
  • Can you update the question with more details about your implementation please, Sounds like something that can be done but without the context, it makes it difficult to help. – Danny Dainton Feb 01 '19 at 13:28

0 Answers0