Forum Discussion

rozdobudko's avatar
rozdobudko
New Contributor
13 years ago

Can't upload document via SoapUI, cURL works

Hi Dear SmartBear support team,

My task is upload document on the service via SoapUI.
I use the latest version -soapUI Pro 4.5.0, Build [internal], Build Date 2012/04/24 00:26.

It's easily uploaded by cURL (I use the following: curl -X POST -H 'Content-Type: multipart/form-data' -F "file=@test.png"<mailto:file=@test.png> http://<some URL> ), and upload is failed when I use SoapUI. Service says about bad request(400). It seems like nothing is uploaded.

How it seems in cURL:

$ curl -X POST -H 'Content-Type: multipart/form-data' -F "file=@test.png"<mailto:file=@test.png> http://<some URL> -v
* About to connect() to <some URL> port 8080 (#0)
* Trying <some IP> ... connected
* Connected to <some URL> (<some IP>) port 8080 (#0
)
> POST /orchestration-web/resource/document/vShopper_test_a_489 HTTP/1.
1
> User-Agent: curl/7.21.1 (i686-pc-mingw32) libcurl/7.21.1 OpenSSL/0.9.8k zlib/1
.2.3
> Host: <some URL>
> Accept: */*
> Content-Length: 6630
> Expect: 100-continue
> Content-Type: multipart/form-data; boundary=----------------------------7d9c1b
6ddf63
>
< HTTP/1.1 100 Continue
< HTTP/1.1 201 Created
< Server: Apache-Coyote/1.1
< Location: <some URL>
< Content-Length: 0
< Date: Fri, 27 Apr 2012 15:32:36 GMT
<
* Connection #0 to host <some URL> left intact
* Closing connection #0

How SoapUI represents it - look in the attachments.

So, my question is how to upload a document via SoapUI(analog to the cURL)?

8 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    Hmm.. have you tried setting the "Media Type" under the parameter table to "multipart/form-data" also?

    regards!

    /Ole
    SmartBear Software
  • DLapus's avatar
    DLapus
    Occasional Contributor
    SmartBear Support,

    I am having Similar issue. Any help is appreciated.

    I have to do a POST request for file upload. here is details of my call.
    1. Attached the file in the tab, set it as multipart/form-data
    2. Need to give some parameter values , which has information where the file will be upload.
    I have put in tab below "media Type" - checked "Post Querystring"
    sample data&colon;
    data
    { "FileBlade": "EBF9EE5649DB449E86F500C869BC2698",
    "FileFolder": "C4FFF652663942828E50E7B2E4499915",
    "ContentLength": 50000,
    "ContentType": "txt"
    }


    when i POST the request i am getting 500 error. when i tried using "REST Console "chrome addon, this is working fine.
    This is my test request:


    ---- start
    POST http://ip/shared/customfiles HTTP/1.1
    Accept-Encoding: gzip,deflate
    Content-Type: multipart/form-data; boundary="----=_Part_2_28697245.1370978871834"
    Authorization: Bearer {b5814f3f-4562-4082-9a36-52a1705b5c4e}
    MIME-Version: 1.0
    Content-Length: 558
    Host: ip
    Connection: Keep-Alive
    User-Agent: Apache-HttpClient/4.1.1 (java 1.5)


    -----=_Part_2_28697245.1370978871834
    Content-Type: multipart/form-data
    Content-Transfer-Encoding: 8bit

    data

    { "FileBlade": "EBF9EE5649DB449E86F500C869BC2698",
    "FileFolder": "C4FFF652663942828E50E7B2E4499915",
    "ContentLength": 50000,
    "ContentType": "txt"
    }


    ------=_Part_2_28697245.1370978871834
    Content-Type: multiform/form-data; name=Prtest.txt
    Content-Transfer-Encoding: binary
    Content-Disposition: form-data; name="Prtest.txt"; filename="Prtest.txt"

    hi world
    ------=_Part_2_28697245.1370978871834--



    SmartBear Support, can you please check and let me know what is wrong here.
    Thanks for the help.
  • DLapus's avatar
    DLapus
    Occasional Contributor
    Please find the screenshot
  • DLapus's avatar
    DLapus
    Occasional Contributor
    Smart Bear Support,

    Any help here is much appreciated.

    Thanks.
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    To attach a file to a REST Request in SoapUI all you need to do is set the request method to POST, the media type to "multipart/form-data" and select the attachments you want to add in the Attachments tab.

    The "Post QueryString" checkbox should only be checked if you want to send query parameters in the body instead of URL, but then you will not send out any attachments.

    Please refer to the documentation at:

    http://www.soapui.org/REST-Testing/unde ... eters.html

    Also notice that if your server returns a 500 code (Internal Server Error: http://www.checkupdown.com/status/E500.html), it does not necessarily mean that SoapUI did not generate the correct request (check the full request in the "http log" tab)... you will have to look at the server log to see what has happened there. It may be something like the "Accept" header was not set correctly for example.

    Regards,

    Renato
    SmartBear Software
  • DLapus's avatar
    DLapus
    Occasional Contributor
    Thanks Renato,

    my server expects a file and also "data value" in request parameters

    data
    Value :
    {
    "FileBlade": "EBF9EE5649DB449E86F500C869BC2698",
    "FileFolder": "C4FFF652663942828E50E7B2E4499915",
    "ContentLength": 50000,
    "ContentType": "txt"
    }

    Please let me know where to put this Data Value ?

    Thanks in Advance.
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    If you want the Json text to be included in the body of the request, just write it down in the white text area just below the "Media Type" combo-box.
    Or just write it in a file and add it as an attachment.

    Regards,

    Renato
    SmartBear Software