Search code examples
httpgrailsmimemultipart

the request was rejected because no multipart boundary was found in Grails


I am trying to send a request with content-type multipart/mixed

and simply print the request in my controller with the line println params

However, I keep getting an error: the request was rejected because no multipart boundary was found

I'm not sure whether this is a problem in grails or my request is messed up. I am using RESTConsole and setting the content-type to multipart/mixed and sending the following as RAW Body:

--boundary42 
Content-Type: text/plain; charset=us-ascii 

...plain text version of message goes here.... 

--boundary42 
Content-Type: text/richtext 

.... richtext version of same message goes here ... 
--boundary42 

Solution

  • multipart/mixed content-type is meant for a text/plain request with an attachment. Do you have an attachment in the request? If you do not send an attachment to the request then it will complain about multipart boundary.

    Try to add an attachment (say a dummy file to the request in REST Console), you should see it working.

    This content-type is mainly used for email contents [SMTP]. Abiding by the boundary, the text/plain content will be transformed to a message body. You can get the message body as HttpServletRequest.getInputStream