soapUI: multipart/form-data REST request with file attachments

十年热恋 提交于 2020-08-16 07:25:11

问题


I am using soapUI for testing a REST web service. Is there a way to attach a file with the other parameters in a multipart request? I see the attachment tab in the panel but I cannot give that attachment a parameter name so that server can identify. It's not helping.


回答1:


I found it but forgot to post it here. It was not so intuitive.

  1. In your REST Request if you can see an attachment tab, open it and add and attachment with + button. The Name of that file would show full path. e.g. C:\temp\my-file.csv
  2. In you parameters tab, add a parameter and give it a name. The value of that parameter will be file:C:\temp\my-file.csv
  3. In SoapUI 5.x and greater, you must select the "Post QueryString" checkbox. Without this, the file will not be send along with the request.

That should be it. When attaching a file if you select Yes when it asks to Cache the file, you won't have to specify full path in step 2 above. The value of file parameter should be file:my-file.csv




回答2:


select mediatype as application/json and then add the json string to that. It will go to server as payload. Usually this request is of POST or PUT type



来源:https://stackoverflow.com/questions/12467901/soapui-multipart-form-data-rest-request-with-file-attachments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!