Reputation: 183
I'm using a database as a data source to transfer properties and values to my test script in SoapUI.
In this case, i have 3 place holders which I'm using as header type and values for my rest test. The problem I'm facing, is how do i get soapUI to ignore a property transfer for header type/value if it is NULL from the database?
I'm finding that Soap UI automatically attempts to send the NULL header property and value for $header_type_2 & $header_type_value_2 even though they are read in as NULL.
IN the raw header request it looks like this:
GET https://api.testapi.test.domain.au:443/v1/ttds/events HTTP/1.1
Connection: close
Accept-Encoding: gzip,deflate
User-Agent: AppName/1.0
:
Authorization: apikey 1233434f7909641458992a7dfebcd3bd311
Host: api.testapi.test.domain.au:443
notice the ':' on the 4th line? this is causing the service to return a 400 bad request.
Screenshot below shows how i've setup my GET REST test step in Soap UI (open source edition)
Upvotes: 0
Views: 739
Reputation: 1209
It's actually a good question. Please note you receive 400 Error only if the Header property name is null, not its value.
It's not easy to "ignore" the header property; instead you can assign a default string to it so it will not throw errors.
To replace Null or Empty with something more tangible, You need to use inline scripting with nested variables. So for your project screenshot it would be something like this:
Header: ${=if ("${header_type_1}"=="" || "${header_type_1}"==null) return "NULL_HEADER_1" else return "${header_type_1}"}
Value: ${header_type_value_1}
Header: ${=if ("${header_type_2}"=="" || "${header_type_2}"==null) return "NULL_HEADER_2" else return "${header_type_2}"}
Value: ${header_type_value_2}
Header: ${=if ("${header_type}"=="" || "${header_type}"==null) return "NULL_HEADER" else return "${header_type}"}
Value: ${header_type_value}
I tested it and works fine. Please give me a plus if you liked it :)
Upvotes: 2