Reputation: 51
I need to be able to do what the red x button does, but in a groovy script:
I tried the following script, but it looks like the empty strings only clear the header and its value, but not delete it:
import com.eviware.soapui.support.types.StringToStringMap
def headers = new StringToStringMap()
headers.put("","")
It seems like there is still a header according to the tab:
Looks like the error is in line 4
Upvotes: 1
Views: 2642
Reputation: 21389
Please use below groovy script. All you need to do is provide the Rest Request test step's name in the below :
import com.eviware.soapui.support.types.StringToStringMap
//Define / change the step name for which headers to be removed.
def step = 'REST Request'
def nextRequest = context.testCase.testSteps[step]?.httpRequest
nextRequest?.requestHeaders = [:]
EDIT: based on OP's comments
Change from:
nextRequest?.requestHeaders = [:]
To
nextRequest?.requestHeaders = [:] as StringToStringMap
Upvotes: 2