cancel
Showing results for 
Search instead for 
Did you mean: 

REST service multipart/mixed request problem

SOLVED
Occasional Contributor

REST service multipart/mixed request problem

Hi!

 

I want to send the below multipart/mixed type of request from SoapUI but I am unable to add the Content-MD5 header to the second part of body. This header is needed, otherwise the request will fail.

My question is: How to add custom headers into a part of multipart request body?

Raw request taken from Fiddler, when response is OK:

 

POST http://srv2012r2:8080/simo/api/documents HTTP/1.1
...

Content-Type: multipart/mixed; boundary=19D523FB
Host: srv2012r2:8080
Content-Length: 11979
Expect: 100-continue


--19D523FB
Content-Type: application/json

 

{

  "fields":[{"Key":"e9e269b9-867f-4cf6-946f-db49091cd52d","Value":"Simplest document ever.docx"}],

  "storageappid":"d9ca0630-e4f8-4112-a411-ff04d89f2225"

}
--19D523FB
Content-Type: application/octet-stream
Content-Disposition: attachment; filename="Simplest+document+ever.docx"
Content-MD5: EFV8OUymEQRJLoppzOjQ1w==

 

PK   ! ߤÒlZ   [Content_Types].xml ¢(   ´”ËnÂ0E÷•ú‘·Ub袪*‹>–-Ré{Vý’Ǽþ¾QU‘
...

--19D523FB--

1 ACCEPTED SOLUTION

Accepted Solutions
Occasional Contributor

Re: REST service multipart/mixed request problem

Attached you can find my solution to the problem.

It is a JavaSript function implemetation of HTTP web request with fully customizable parameters and the call of function with needed parameters for this teststep.

10 REPLIES 10
Regular Contributor

Re: REST service multipart/mixed request problem

I don't think this is feasible through SoapUI to add a custom header to an attachment. Also, I see the 3rd part of the multipart request is a word document, which is converted to a binary stream. As a work around, I would suggest you to manually edit the request passed by SoapUI through some web debugger tools like Fiddler, HTTP Watch, Burp Suite etc., and add the header (Content-MD5: EFV8OUymEQRJLoppzOjQ1w==) manually using the "Recompose" options,

 

Fiddler integration with SoapUI - Reference - http://www.codeproject.com/Articles/249303/Testing-and-Monitoring-WCF-Service-using-soapUI-an

 

Thanks,

Samy

 

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others, Thanks. ↓↓↓

Occasional Contributor

Re: REST service multipart/mixed request problem

No problem, I already solved it with a GroovyScript/JavaScript teststep Smiley Wink

 

Edit:
If anybody wants an example, just reply here and I will post it.

Highlighted
Regular Contributor

Re: REST service multipart/mixed request problem

It would be great, if you post the solution here! Smiley Happy

 

Thanks,

Samy

Occasional Contributor

Re: REST service multipart/mixed request problem

Attached you can find my solution to the problem.

It is a JavaSript function implemetation of HTTP web request with fully customizable parameters and the call of function with needed parameters for this teststep.

Community Hero

Re: REST service multipart/mixed request problem

@lheller
Would mind providing some description, how to use it? As you know, it would save some one.


Regards,
Rao.
Occasional Contributor

Re: REST service multipart/mixed request problem

Project must be switched to use JavaScript instead of GroovyScript and reopened.
My script can be used as a TestStep (of type JavaScript - but in UI there label of teststep is still GroovyScript).
It has the main function called invokeWebRequest, which can be used for custom call against any Rest or Soap endpoint.
Although the function is universal it's up to you how you use it. In that script there is an example near at the end.

The simplest example of usage:

 

var res = invokeWebRequest("GET","https://www.google.com/",new java.util.Hashtable(),new java.lang.String())
if (res == null) throw "TestStep failed!"

The above simply "navigates" to "www.google.com" and downloads the content of start page.

Community Hero

Re: REST service multipart/mixed request problem

Thank you for your time, and adding details.


Regards,
Rao.
New Member

Re: REST service multipart/mixed request problem

HI,

i have a similar problem with call of SAP S/4 Hana Cloud API; the biggest doubt is on the correct syntax of the batch call.  Attached to this post the request I am using for the batch call.

 

How can I POST correctly using your javascript?

Occasional Contributor

Re: REST service multipart/mixed request problem

Hello

This was a long time ago...
Unfortunately I am not using the SoapUI tool anymore and my own script tells me almost nothing :-/
But what I see from your request, only the request body is different from mine so you can try to change the part tagged with comment
MAIN PART OF SCRIPT STARTS HERE.

You have to build your own request body there using
body.append(...)
calls

New Here?
Join us and watch the welcome video:
Top Kudoed Authors