Forum Discussion

danielatsi's avatar
danielatsi
New Contributor
7 years ago

Problem with content-type when attaching file to SoapUI rest request

Hello,

can somebody help me with the following issue that I have when trying to attach a file to Rest Post request?

 

I want to attach a .png file to my rest request in SoapUI free version, the problem is that SoapUI puts in the Raw of the request Content-Type: image/x-png instead of image/png

 

It looks like this in the Raw tab:

 

Content-Type: image/x-png
Content-Transfer-Encoding: binary
Content-Disposition: form-data; name="energy.png"; filename="energy.png"

 

and my server is expecting content-type image/png, for which reason I am getting error: errorMessage": "File must be in one of the following formats: [image/png]

 

I have a QUERY parameter in my request with value file:filename, where filename is the complete path to the file on the local hard drive (that was the way to avoid appending the file name together with file type in the Content-type in Raw)

 

Thank you!

 

4 Replies

    • danielatsi's avatar
      danielatsi
      New Contributor

      Thank you Nastya! I have already tried that way, and this is exactly the way I am working with, but it didn't help.

      • Nastya_Khovrina's avatar
        Nastya_Khovrina
        SmartBear Alumni (Retired)

        To find the cause of the issue, compare a successful (or expected) raw request with a raw request from ReadyAPI and change the request accordingly. 

        To get a raw request in ReadyAPI, please switch to the Raw tab on the left side of the Request Editor.

        To get a raw request which was sent from a browser (or from another application) you can use Fiddler (http://www.telerik.com/download/fiddler) which is a free tool to capture HTTP(S) traffic.