cancel
Showing results for 
Search instead for 
Did you mean: 

automatically add request header to all calls

SOLVED
Super Contributor

automatically add request header to all calls

Hello,
I have project with many testcases already scripted. We now have a changing requirement such that all REST calls need to have header specified with a sessiontoken.
Is there a better way to do this then to go to each REST step and add this header ?

Thanks

Ali
1 ACCEPTED SOLUTION

Accepted Solutions
Community Expert

Re: automatically add request header to all calls

If you are still looking for a solution there is one here.

View solution in original post

7 REPLIES 7

Re: automatically add request header to all calls

Hi Ali,

you could add it dynamically to all requests with an outgoing request filter.. would that be an option?

regards!

/Ole
eviware.com


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓
Super Contributor

Re: automatically add request header to all calls

might be an option if its fairly simple to do.

Ali

Re: automatically add request header to all calls

Hi!

then try adding a RequestFilter.filterRequest event with the following:

def headers = request.requestHeaders
headers.put( "test-header", "test" )
request.requestHeaders = headers

This should set a "test-header" header on all outgoing requests.. could you use this?

regards,

/Ole
eviware.com


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓
Contributor

Re: automatically add request header to all calls

I know this is really old, but in case somebody finds it via web search:

 

You can (at least now) add "Header" parameters up at the Resource level. They'll be copied down to all requests under them.

Frequent Contributor

Re: automatically add request header to all calls

hi,

that sounds great, but what if you have 500 resources ?  Smiley Sad

Is there any way to apply a header to ALL of your resources ?

 

EDIT : ok, the upper method works fine

"then try adding a RequestFilter.filterRequest event with the following:

def headers = request.requestHeaders
headers.put( "test-header", "test" )
request.requestHeaders = headers"

 

Well, in fact it works pretty well ... too well: at each call, the header is added. It should happen only once.

I'm trying to find a way to make it a 'one-shot' process ...

Anyone has already been through this ?

 

 

thanks

 

Alex

Community Expert

Re: automatically add request header to all calls

If you are still looking for a solution there is one here.

View solution in original post

Moderator

Re: automatically add request header to all calls

Thanks for sharing the solution, @SiKing!

 


Olga Terentieva
SmartBear Assistant Community Manager