Forum Discussion
kondasamy
10 years agoRegular Contributor
I have a script, which would add the additional header field without disturbing the existing headers. Please feed this script in a Groovy test step and execute. This would apply the new header for all the REST request within the project.
import com.eviware.soapui.support.types.StringToStringMap //Get through all the test steps in the project testRunner.testCase.testSuite.project.testSuites.each { suite -> suite.getValue().testCases.each { q1-> q1.getValue().testSteps.each { it-> if (it.getValue().config.type.equals("restrequest")) { //Get the headers of the current teststep def headers = it.getValue().getHttpRequest().getRequestHeaders() def list = [] //Append the new header to the existing list list.add("en;q=0.8") headers["Accept-Language"] = list; //Set the updated header list it.getValue().getHttpRequest().setRequestHeaders(headers) } } } } log.info("************************************************\n Done ! New Header Appended to all teststeps!\n************************************************ ")
Hope this answers your need!
Thanks,
Samy
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others, Thanks. ↓↓↓
Related Content
- 6 months ago
- 6 years ago
Recent Discussions
- 15 years ago