Forum Discussion

ezuser's avatar
ezuser
Occasional Visitor
6 years ago

Generated code .net 2.0 - How to add Cookie to the header ???

I need urgent help:

I generated some C# code from SOAPUI useing "Generate Code" - ".net 2.0" tool.
It works nicely when I need just to pass fields to the request.
But I can not find correct way to pass to it cookies that is used in the header.

What object can I use for it?

In previous version of this task that do not use generated code I have used something like this:

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(destinationUrl);

     request.Headers.Add("Cookie", "LoginCert=" + token);

1 Reply

  • aaronpliu's avatar
    aaronpliu
    Frequent Contributor

    Hi ezuser,

     

    If you would like to add parameter (like cookie) to Header, then you may use below scripts:

     

    import com.eviware.soapui.support.types.StringToStringMap
    def teststep = testRunner.testCase.testSteps["YourStepName"]
    teststep.testRequest.setRequestHeaders(new StringToStringMap(["cookie": "YourCookie"]))