Forum Discussion

pf's avatar
pf
Occasional Contributor
16 years ago

Adding http-header using groovy

Hi

I have a test case where I need to add a http-header (due to security reasons) before sending the soap request. The header is dynamically created using a coresponding java class.

Is it possible to add an http-header using groovy before sending the request? If yes, is there any example script available?

many thanks
erhard

2 Replies

  • omatzura's avatar
    omatzura
    Super Contributor
    Hi Erhard,

    sure, please try the following:

    def request = testRunner.testCase.testSteps["Request Step"].testRequest
    def headers = request.requestHeaders
    headers["another header"] = "another value"
    request.requestHeaders = headers


    works ok?

    regards!

    /Ole
    eviware.com
  • pf's avatar
    pf
    Occasional Contributor
    Hej Ole

    thanks for your fast response. The script works fine

    best regards,
    Erhard