REST – Is It Correct to Use PUT with Multipart Content

httphttp-requestrestspring

We are using Spring and want to implement a REST with a "override file" call so we think using PUT verb with a multipart body only to find that Spring don't accept it.

My question is it can't be done in Spring because it isn't the REST way to have a multipart body with PUT?

Note: I know there are ways to skip this restriction in Spring or that I can use POST but I want to stick to REST style if possible.

Best Answer

If you GET the same resource at the same URI, what do you expect to get back? Do you expect to get the same multipart content that you sent, i.e. the data and the file, or just one of them?

If it's the latter, then it's not a RESTful use of PUT, since one URI no longer refers to one resource. You would be better off considering using POST, or splitting the multipart content into two separate resources.

Related Topic