Forum Discussion
bagochips
7 years agoContributor
Are you using the attachment tab in your POST request?
For a project I have I added a groovy step to encode an attachment to use in the body of my POST request
// Set results file path def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context) def projectDir = groovyUtils.projectPath folder = projectDir+"\\Results\\"; resultFile = context.testCase.getPropertyValue("TestResultsFile") if (resultFile != '') { resultFilePath = folder + resultFile testRunner.testCase.setPropertyValue("resultFilePath", resultFilePath ) // encode file ResultsPath = context.testCase.getPropertyValue("resultFilePath") def inputFile = new File(ResultsPath) String encoded = inputFile.bytes.encodeBase64().toString() testRunner.testCase.setPropertyValue("EncodedFileRequest", "$encoded" ) // get request def request = testRunner.testCase.getTestStepByName( "AttachmentContentRequest" ).testRequest log.info request // clear existing attachments for( a in request.attachments ) { request.removeAttachment( a ) } // get file to attach //ResultsPath = context.testCase.getPropertyValue("resultFilePath") def file = new File(ResultsPath) log.info file if ( file == null) { log.info "bad filename" } else { // attach and set properties def attachment = request.attachFile( file, true ) //attachment.contentType = "application/octet-stream" attachment.contentType = "base64Binary" attachment.setPart( "Message" ) } }else{ testRunner.gotoStepByName("Loop") }
Then pass the values that are need in the attachment tab. The image of from SoapUI Pro but it also works with the non pro
Related Content
- 2 years ago
- 8 years ago