cancel
Showing results for 
Search instead for 
Did you mean: 

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

danielatsi
New Contributor

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 4
Nastya_Khovrina
Moderator

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

Hi,

 

Thank you for your post. To learn how to send an attachment with parameters specified in the QUERY string, please refer to the following article: https://support.smartbear.com/readyapi/docs/projects/requests/attachment/rest.html



Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
danielatsi
New Contributor

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

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

PaulMS
Super Contributor

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

Can you change the content type on the attachments tab in the request?

 

https://www.soapui.org/docs/soap-and-wsdl/attachments.html

Content type
The MIME type of the attachment. This type will be specified in the Content-Type header of the request body part:

SoapUI determines this column value automatically when you add a file to the Attachments tab. If needed, you can enter any other value later.

Nastya_Khovrina
Moderator

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

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.



Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors