Forum Discussion

alibaba82's avatar
alibaba82
Super Contributor
15 years ago

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
  • If you are still looking for a solution there is one here.

  • 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.

    • krogold's avatar
      krogold
      Regular Contributor

      hi,

      that sounds great, but what if you have 500 resources ?  :(

      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

      • SiKing's avatar
        SiKing
        Community Expert

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

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    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
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi Ali,

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

    regards!

    /Ole
    eviware.com