Forum Discussion

Accelrys_Inc__S's avatar
13 years ago

Adding http-header using groovy getting NULLPointerExpection

Hi

I have a test suite created using REST service where I need to add a http-header (due to security reasons) before sending the REST request. The header is dynamically created.

Tried to add an http-header using groovy before sending the request.

import com.xxxx.security.TokenCacheManager
import com.xxxxx.security.SecurityToken


def manager = TokenCacheManager.getInstance()
manager.configure("Domai/Username", "password", "https://servername with port no/SecurityTokenService/sts")

def token = manager.getToken()
def request = testRunner.testCase.testSteps["Request1"].testRequest
def headers = request.requestHeaders
headers["Authorization"] = token.toHttpAuthorizationHeader();
request.requestHeaders = headers


When running above script in Setup Script(groovy script) getting java.lang.NullPointerException error.

I have set my file path to C:\Program Files\SmartBear\soapUI-Pro-4.5.0\bin\ext.

I followed the sample given by Samrtbear in
http://papsrv01.eviware.com/forum/viewtopic.php?f=2&t=742&p=2737&hilit=groovy+script+header#p2737
  • Hi,

    hmm... can you figure out on which line you are getting the NPE?

    regards,

    /Ole
    SmartBear Software