Forum Discussion

Oxnard's avatar
Oxnard
New Contributor
7 years ago

file data embedded in json

using SoapUI 5.1.3 doing a post request have selected Media Type of application/json the json looks like {  "myname":"Ox" }   I have added an attachment but there does not seem to be a way to...
  • JHunt's avatar
    7 years ago

    For SOAP TestRequests we have an option called Inline Files, which lets you set the file as an Attachment and refer to it in the body of the request to put the file data inline.

     

    This isn't available for REST requests, but it's not much harder to use an inline script:

     

    {
        "myname":"Ox"
        "file":"${=new File("C:/somefile").bytes.encodeBase64()}"
    }

    (Presuming you want to insert the file encoded as base 64)

     

    You don't need to attach the file to the request, but you will need to give an absolute path to the file on disk.