Use testCase custom property to create dynamic request header in event
I created an event to use RequestFilter.filterRequest to populate REST call headers. Most of the testCases use "Accept, application/json" as header while some special testCases require "Accept, application/octet-stream". I include a custom property "Accept" in the special testCases and hope when event gets executed the Accept header can be populated dynamically. But the actual execution completely skip the if-else section. May I know did I miss anything?
import com.eviware.soapui.support.types.StringToStringMap
def headers = new StringToStringMap()
headers.put("Authorization", "Basic abcxyz123456....")
headers.put("Cache-Control", "no-cache")
headers.put("Pragma", " no-cache")
headers.put("Expires", " Sat, 01 Jan 2000 00:00:00 GMT")
headers.put("Content-Type", "application/json")
if(testRunner.testCase.hasProperty("Accept")) {
headers.remove("Accept")
headers.put("Accept", "application/octet-stream")
} else {
headers.put("Accept", "application/json")
}
request.setRequestHeaders(headers)