Forum Discussion
you can add headers for HTTP REST or SOAP from the request. look at the bottom of your request screen there are options for it.
see highlighted part of attached image
- Optical_Image_T9 years agoOccasional Contributor
IS there a script that can add it too all?
I have been doing that manually, but we have tons of test steps?
- faizmuhammad9 years agoOccasional Contributor
there is an alternate way i.e. VIA groovy.
//////////////////////////
import com.eviware.soapui.support.types.StringToStringMap
def headers = new StringToStringMap()
headers.put("Header1","value123")
testRunner.testCase.getTestStepByName("HTTP Request").testRequest.setRequestHeaders(headers)///////////////////////////
in above script
Header1 is the name of header
value123 is the value of Header1
and HTTP Request is the name of test step
if you have many test step you can do multiple iteration using this code.
let me know if you need further help.
- Optical_Image_T9 years agoOccasional Contributor
Using this code I can print each step name, But now how do I add the headers?
import com.eviware.soapui.support.types.StringToStringMap def headers = new StringToStringMap() headers.put("Cookie","XSRF-TOKEN=soap;") headers.put("X-XSRF-TOKEN","soap") def testCases = testRunner.testCase testCases.each { for(testStep in it.testStepList) { log.info "~~~Test Step:" + testStep.name //testStep.testRequest.setRequestHeaders(headers) } }
Related Content
- 6 years ago
Recent Discussions
- 15 years ago