Forum Discussion

Jass's avatar
Jass
New Contributor
8 years ago

Upload File in Request Body with different Content-Type and Content-Encoding in SoapUi

Dear SoapUi Team,

first of all thank you for the software you provide.
I am impressed by the rich features implemented.

Sadly I am currently struggling a bit with SoapUi, but I am sure you can help me with that.
I want to send binary data as an attachment in the body of a request to a REST API.
The attachment is in the body, when the Content-Type and the Content-Encoding Header have the same value, as explained here:
https://sqa.stackexchange.com/questions/22224/how-do-you-send-a-zip-file-in-the-request-body-in-soapui-readyapi

The thing is that I am sending gzipped Json Data in the body.
That means that the correct Content-Type is application/json and the Content-Encoding is application/gzip.

 

Why is the body empty when I set the Content-Type to application/json  and the Content-Encoding to application/gzip?

Thank you for your help on this.

Thank you,
Jonas

  • Jass's avatar
    Jass
    New Contributor

    Since nobody responded to this question I wanted to give an update.

     

    I tried to do upload the binary data with postman. That worked just fine.

    Still I need to get it running with SoapUi.

     

    I tried to change the header values with a groovy script. But that doesn't seem to work either.

    • nmrao's avatar
      nmrao
      Champion Level 3
      The stackoverflow thread you linked above seemed to be resolved. Isn't it so?
  • Jass's avatar
    Jass
    New Contributor

    Hi nmrao,

     

    thank you for your reply!

    The solution posted on stackexchange in the link above can not be adopted to my use case.

     

    They advise, that SOAP UI only sends binary data in the request body if "Media Type" matches the "Content Type" attribute.

    "Media Type" is the "Content-Encoding" HTML header.

     

    What I need is, to send binary data in the request body without "Media Type"/"Content-Encoding" matching the "Content Type".

     

     

    Maybe an example would be helpful:

     

    This is a HTTP header setup the way I need it to work:

    POST https://example.com/rest/provider/v1/masterData/landscape
    Accept-Encoding: gzip,deflate
    Content-Type: application/json
    Content-Encoding: application/gzip
    Content-Length: 0
    Host: c5244789devcacenterwa05130b1.int.sap.hana.ondemand.com
    Connection: Keep-Alive
    User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

     

    Notice that the Content-Type and Content-Encoding have different values.

    The problem with the request set up like this, SoapUi will send an empty body! The request body will not contain the data defined as attachment.

     

     

     

    Now this is how SoapUi sends a request body that contains the data defined as attachment:

    POST https://example.com/rest/provider/v1/masterData/landscape
    Accept-Encoding: gzip,deflate
    Content-Type: application/gzip
    Content-Encoding: application/gzip
    Content-Length: 0
    Host: c5244789devcacenterwa05130b1.int.sap.hana.ondemand.com
    Connection: Keep-Alive
    User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

     

    Notice that the Content-Type and Content-Encoding have the same values, as suggested on stackexchange.

     

    Thank you again for your reply! I hope with the new information we can find a solution for this problem.