Forum Discussion

Ameer's avatar
Ameer
New Contributor
10 years ago

How to add Authorization Header to a Rest Request in Java

Hi,   I am newbie to SOAP UI java Api's. Could you please help me on setting Authorization Header to a Rest Request for a test suite in java.    Please find the Step:   WsdlProject wadlProject ...
  • kondasamy's avatar
    kondasamy
    10 years ago

    Same way it is! Here is a sample snippet for your reference,

    import com.eviware.soapui.support.types.StringToStringMap 
    def headers = new StringToStringMap()
    headers.put("Header1","Value 1")
    headers.put("Header2","Value 2")
    headers.put("Authorization","Basic fgfhgfdhCGDGRSGFEWRGFBGHLI")
    testCaseRunner.testCase.getTestStepAt(1).testRequest.setRequestHeaders(headers)

    Thanks,

    Samy

     

    Did my reply answer your question? Give Kudos or Accept it as a Solution to help others, Thanks. ↓↓↓