Forum Discussion

tsui's avatar
tsui
New Contributor
9 years ago

Service V | Set header when a requested is received

Hi,

 

I am using ServiceV Pro's "Sample Virtualization Project" (RESTMockService) that is receiving HTTP POST requests with a content-type = application/octet-stream.

 

Before process the request I need to change this content-type to gzip

 

In this link: http://www.soapui.org/scripting---properties/custom-event-handlers.html I saw that with events is possible to modify the header, however I am not sure if this solution can resolve my problem.

 

Can someone please help and let me know how I can change the content-type of the request received?

 

Thanks,

Tsui

 

 

3 Replies

    • tsui's avatar
      tsui
      New Contributor

      Hi Tanya,

       

      I am afraid that this example does not solve my problem. 

      The request is sent from a outside server, so I don't have access to the request.

       

      I just need to get this request and modify the content-type to "gzip" before that is read by my mock.

       

      I'm looking for a solution, can someone help me with this issue please?

       

      Thanks

       

       

      • TanyaYatskovska's avatar
        TanyaYatskovska
        SmartBear Alumni (Retired)

        Hi Tsui,

         

        I’ve found the following sample Groovy script:

        def tstep = testRunner.testCase.getTestStepByName("REST http call")
        
        tstep.testRequest.setMediaType('application/json')

         

        Give it a try (specify your content-type) and let me know how it works for you.