Forum Discussion

Optical_Image_T's avatar
Optical_Image_T
Occasional Contributor
8 years ago

How I add HTTP headers to all HTTP requests in a project,

We have SOAP UI 5.1.1, and we have a SOAP test project and a REST test project in it.

 

We have a bunch of HTTP requests in the SOAP project and all the requests in the REST Test project need  new HTTP headers.

 

If there any script which will add these headers to all my requests , versus me having to do it manually?

7 Replies

  • faizmuhammad's avatar
    faizmuhammad
    Occasional Contributor

    you can add headers for HTTP REST or SOAP from the request. look at the bottom of your request screen there are options for it. 

     

    see highlighted part of attached imageAdd headers & Auth

    • Optical_Image_T's avatar
      Optical_Image_T
      Occasional Contributor

      IS there a script that can add it too all? 

       

      I have been doing that manually, but we have tons of test steps?

      • faizmuhammad's avatar
        faizmuhammad
        Occasional Contributor

        there is an alternate way i.e. VIA groovy.

         

        //////////////////////////

        import com.eviware.soapui.support.types.StringToStringMap

        def headers = new StringToStringMap()
        headers.put("Header1","value123")
        testRunner.testCase.getTestStepByName("HTTP Request").testRequest.setRequestHeaders(headers)

        ///////////////////////////

         

        in above script

        Header1 is the name of header

        value123 is the value of Header1

        and HTTP Request is the name of test step

         

        if you have many test step you can do multiple iteration using this code. 

         

        let me know if you need further help.