#200 REST support for multi-part post

open
nobody
None
5
2008-11-11
2008-11-11
Kyle
No

Note I asked some questions on the blog and it was suggested a make a feature request as the requested capabilities are not yet supported.

The basic request is for multi-part POST support within REST for uploading file assets.

Here is the AWS example of a multi-part post which I don't think can currently be supported by SoapUI. This is one good example of something which it would be nice to add support for. There is a second example lower down.

----------- AWS Example -----------------

POST / HTTP/1.1
Host: destinationBucket.s3.amazonaws.com
User-Agent: browser_data
Accept: file_types
Accept-Language: locales
Accept-Encoding: encoding
Accept-Charset: character_set
Keep-Alive: 300
Connection: keep-alive
Content-Type: multipart/form-data; boundary=---------------------------9431149156168
Content-Length: length

-----------------------------9431149156168
Content-Disposition: form-data; name="key"

filepath
-----------------------------9431149156168
Content-Disposition: form-data; name="acl"

acl
-----------------------------9431149156168
Content-Disposition: form-data; name="success_action_redirect"

success_redirect
-----------------------------9431149156168
Content-Disposition: form-data; name="Content-Type"

content_type
-----------------------------9431149156168
Content-Disposition: form-data; name="x-amz-meta-uuid"

uuid
-----------------------------9431149156168
Content-Disposition: form-data; name="x-amz-meta-tag"

metadata
-----------------------------9431149156168
Content-Disposition: form-data; name="AWSAccessKeyId"

access-key-id
-----------------------------9431149156168
Content-Disposition: form-data; name="Policy"

encoded_policy
-----------------------------9431149156168
Content-Disposition: form-data; name="Signature"

signature=
-----------------------------9431149156168
Content-Disposition: form-data; name="file"; filename="MyFilename.jpg"
Content-Type: image/jpeg

file_content
-----------------------------9431149156168
Content-Disposition: form-data; name="submit"

Upload to Amazon S3
-----------------------------9431149156168--

------------ Other Example -------------
The other example I have is that I was trying to test a existing service which can accept the following cURL command (where imageIn is a image/jpeg file):

curl -s -F image1=@${imageIn} "myemail@mydomain.com" target="_blank">http://host/site/rest/image/upload?email=myemail@mydomain.com"

I was also told that this cannot be modeled yet and I should submit a feature request.

Discussion

1 2 > >> (Page 1 of 2)
  • Hi!

    thanks! I see two requests here:

    1) support multipart/form-data requests (query parameters are sent as mime parts)
    2) support file / cid references in query parameters (for inlining files/attachments)

    have I understood correctly?

    regards!

    /Ole
    eviware.com

     
  • Kyle
    Kyle
    2008-11-11

    Yes Ole, I think you are right. I wasn't sure how to break this up but I think it really is the two requests you have identified.

    thanks much.

     
  • Kyle
    Kyle
    2008-11-11

    Yes Ole, I think you are right. I wasn't sure how to break this up but I think it really is the two requests you have identified.

    thanks much.

     
  • Ole Lensmar
    Ole Lensmar
    2008-11-12

    Hi again,

    ok, there is a new nightly-build at http://www.eviware.com/nightly-builds that supports this; set the method to POST and select multipart/form-data for the mediaType in the drop-down. All paramerts and attachments will be added as mime parts. Paramaters with values starting with "file:<filename>" will attach the corresponding file..

    Let me know how this works for you!

    regards,

    /Ole
    eviware.com

     
  • Kyle
    Kyle
    2008-11-13

    Hi,

    so somethings did work with this nightly build (I can setup the file:<filename> and it does seem to send it. However I also get a number of null pointer exceptions doing things. So my question is how to debug into this? Is there a way you share your source and to get this nightly build I can pull the source and build it myself? I haven't seen directions on this yet.

    In a momement I will provide more details on a simple issue in the 11/12 nightly build.

    I try to implement the folowing service:
    http://udma-workday_ss001.devel.mydomain.com:8180/upload-site/rest/v1.0/albumList?email=anthony@gmail.com

    what I get is:
    java.lang.NullPointerException
    at com.eviware.soapui.impl.wsdl.submit.filters.RestRequestFilter.filterRestRequest(RestRequestFilter.java:71)
    at com.eviware.soapui.impl.wsdl.submit.filters.AbstractRequestFilter.filterAbstractHttpRequest(AbstractRequestFilter.java:37)
    at com.eviware.soapui.impl.wsdl.submit.filters.AbstractRequestFilter.filterRequest(AbstractRequestFilter.java:29)
    at com.eviware.soapui.impl.wsdl.submit.transports.http.HttpClientRequestTransport.sendRequest(HttpClientRequestTransport.java:117)
    at com.eviware.soapui.impl.wsdl.WsdlSubmit.run(WsdlSubmit.java:118)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

    Ergo my request above on how I can debug these issues.

    Again somethings did get fixed with the change you put in but I'm still hitting lot's of issues where it is difficult to figure what is going on.

    Kyle

     
  • Ole Lensmar
    Ole Lensmar
    2008-11-13

    Hi!

    thanks.. there is a newer build out that fixes this bug, but you can also work against the source trunk as described at http://www.eviware.com/blogs/oleblog/?p=126

    regards!

    /Ole
    eviware.com

     
  • Kyle
    Kyle
    2008-11-14

    Hi,

    so the multi-part post changes you put in still do not work on the service I am trying to test. The issue seems to be in the content-type. SoapUI puts additional values here verses what the service expects and I cannot figure out how I can control these values.

    I have included a copy of what the service does expect. And then a snippet of what SoapUI is producing. I have also included an html page which produces the right form post just in case. And the soapui log.
    This was done with the nightly build from 11/13/08 (I think - this is what I have been using but someone else made the

    log).

    Our upload service expects request as follows (this from fiddler based on attached html form):

    POST /site/rest/v1.0/album/41775025933/upload?email=anthony@kodakgallery.com HTTP/1.1
    Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint,

    application/msword, application/xaml+xml, application/vnd.ms-xpsdocument, application/x-ms-xbap,

    application/x-ms-application, application/x-shockwave-flash, */*
    Accept-Language: en-us
    Content-Type: multipart/form-data; boundary=---------------------------7d82329d0624
    UA-CPU: x86
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR

    3.0.04506.30)
    Host: udma-workday_ss001.devel.ofoto.com:8180
    Content-Length: 780621
    Connection: Keep-Alive
    Pragma: no-cache

    -----------------------------7d82329d0624
    Content-Disposition: form-data; name="image1"; filename="C:\SuperDadPoster.jpeg"
    Content-Type: image/pjpeg

    ����

    NOTE: Content-type should be specified as highlighted above.

    However SoapUI is sending the content-type as follows (see attached log file for more details):

    Content-Type: multipart/related; type="multipart/form-data"; start="<rootpart@soapui.org>";

    boundary="----=_Part_0_24749863.1226692237956"

    Our service has an issue with this and throws the following error:
    com.kin.assembler.errors.UnsupportedContentTypeException: Request Content-type is null or invalid : Request Content-type is

    invalid : multipart/related; type=multipart/form-data; start=<rootpart@soapui.org>;

    boundary=----=_Part_0_24749863.1226692237956

    Thanks much for your assistance. I've long been a strong advocate for SoapUI and would love to use it for REST testing.
    File Added: FileUploadForm.htm

     
  • Kyle
    Kyle
    2008-11-14

    html form which shows how service is invoked

     
    Attachments
  • Kyle
    Kyle
    2008-11-14

    File Added: SoapUIMultipartFormRequest.txt

     
  • Kyle
    Kyle
    2008-11-14

    SoapUI log file (Night build 11/13/08 with truncated binary data)

     
1 2 > >> (Page 1 of 2)