Forum Discussion

bkbn16's avatar
8 years ago

Unable to fetch response JPEG attachments

For the past few days, I have been trying to create a POST response with a image attached (JPEG). I need to get the output as response attachment in JPEG format. How can I do this ? Please see the attachments that I have posted on the procedure that I have followed to do this ...

3 Replies

  • nmrao's avatar
    Champion Level 3
    You need to create a test suite -> test case and add the test step and then try attaching it. You can't use the attachment from the rest method definition which you doing it currently.
    • bkbn16's avatar



      I followed your instructions, created a REST project and under that Test Suite > Test Case > Test Script. Then I created a httprequest. I uploaded a image jpeg file. Along with the httprequest, I am writing a Groovy script to fetch the same uploaded image file as response. I have been followng the thread "" to do the same.


      My script is like this:


      import java.lang.*
      import java.util.*
      import groovy.lang.*
      import groovy.util.*
      import java.math.BigInteger
      import java.math.BigDecimal
      import javax.servlet.http.*
      def groovyUtils=new
      import com.eviware.soapui.model.iface.*

      def ImageReq = testRunner.testCase.testSteps['LeeChin'].httpRequest.getAttachmentAt(0) /* This points to the Request Attachment properly */

      def ImageResponse = testRunner.testCase.testSteps['LeeChin'].httpRequest.response
      //assert null != response, "response is null"
      def outFile = new FileOutputStream(new File(System.getProperty('')+'/'))
      def ins = ImageResponse.getAttachmentAt[0].inputStream /* error */
      if (ins) { outFile, ins )


      When I run the script; I get an error No such property "getAttachmentAt"; then I changed it to "responseAttachments"

       I again get the same error; what am I doing wrong ?

      • nmrao's avatar
        Champion Level 3
        Please show the screen shot of your request?