Forum Discussion

rodgersh's avatar
rodgersh
Occasional Contributor
12 years ago

How to POST multipart/form-data with soapui 4.0.1 (free)

I am trying to POST a multipart/form-data with 2 form-data parts. The first part is a String, name="directive" and value="STORE_AND_PROCESS". The second part is the contents of a file (as opposed to a file attachment).

So the POST request looks like this:

***************************************************

POST http://172.18.14.169:8181/services/content/ HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: multipart/form-data; boundary="----=_Part_1_1530692737.1361832805105"
MIME-Version: 1.0
User-Agent: Jakarta Commons-HttpClient/3.1
Host: 172.18.14.169:8181
Content-Length: 10042

------=_Part_1_1530692737.1361832805105
Content-Type: multipart/form-data
Content-Transfer-Encoding: 8bit

----=_Part_0_514145621.1361832485399
Content-Disposition: form-data; name="directive"
STORE_AND_PROCESS
----=_Part_0_514145621.1361832485399
Content-Disposition: form-data; name="file"; filename="C:\path\to\myfile.json"
Content-Type: application/json

{ "properties":{ "title": "myTitle" } }

*****************************************************

I entered the parts into the text area beneath the Media Type drop down (which I set to multipart/form-data). I do not have a Form tab on the REST Test Request screen (is this a soapui Pro feature only?), hence the reason I entered all of this text by hand into this text area.

My REST service is failing to process this request, possibly because the boundary is assigned by soapUI when I send the request and is different than the boundary I entered into the text area.

So how do I send a multipart/form-data POST request using soapUI 4.0.1 free version? (I am on Windows 7).

Thanks.
  • This is my POST request form- data in profile Update ---

     

     -----------------------------2638131683482
    Content-Disposition: form-data; name="user_photo"; filename="1451456913_brodie.jpg"
    Content-Type: image/jpeg

    Content-Disposition: form-data; name="first_name"

    dsfsdfsd
    -----------------------------2638131683482
    Content-Disposition: form-data; name="last_name"

    jjjj

    -----------------------------2638131683482
    Content-Disposition: form-data; name="mobile_no"

    12456666
    -----------------------------2638131683482
    Content-Disposition: form-data; name="address"

    sdfsdf
    -----------------------------2638131683482--

     

     Please  see below screenshot , which I set up for this request. [SoapUI 5.0.1]

     

           Note -- 1. Select media-type -- multipart/form-data

                       2. Check Post Query String checkbox.

     

                  I got success message in JSON response "Profile was updated successfully.

     

  • sesleri's avatar
    sesleri
    New Contributor

    I am having the same issue.  Does anyone have solution?