Forum Discussion
Hmm, if this was a SOAP request then there's an option for "Inline Files" but there isn't the same option for REST.
In the source code (com.eviware.soapui.impl.wsdl.submit.transports.http.support.attachments.AttachmentUtils), the implementation for SOAP boils down to this, which is fairly straightforward:
//...
String content = null; byte[] data = Tools.readAll(in, -1).toByteArray(); //... content = new String(data); //...
So, you can use the workaround Paul referred to, plus use an inline Groovy script to inline the file contents:
Content-Type: multipart/form-data; boundary="----someboundary"
------someboundary
Content-Type: application/octet-stream; name="audio.mp3"
Content-Transfer-Encoding: binary
Content-Disposition: form-data; name="audio.mp3"; filename="audio.mp3"
${=new String(new File('audio.mp3').bytes)}
Note that the boundary value in the body needs two more hyphens than the boundary value in the header.
To my eye, the request generated seems identical to a normal REST request with attachments, except for the boundaries. Plus if I send it to a local MockService it seems to parse it ok. So there's every chance this might work for you.
Related Content
- 6 years ago