Using Rest Client Chrome tool, I am uploading a JSON file say sample.json in my request. Getting below exception. Tried Passing header as multipart/form-data and also no passing the latter. But the result is same. Am I doing right?
the request
was rejected because no multipart boundary was found
..
public HttpEntity<?> uploadJsonFile(@PathVariable("jsonFileID") String
jsonFileID, @RequestParam("file") MultipartFile file) throws Exception
{
// Some code here
}
..
Failed to parse multipart
servlet request; nested exception is java.io.IOException:
org.apache.tomcat.util.http.fileupload.FileUploadException: the request
was rejected because no multipart boundary was found] with root cause
org.apache.tomcat.util.http.fileupload.FileUploadException: the request
was rejected because no multipart boundary was found
at org.apache.tomcat.util.http.fileupload.FileUploadBase$FileItemIteratorImpl.<init>(FileUploadBase.java:831) ~[tomcat-embed-core-8.5.32.jar:8.5.32]
at org.apache.tomcat.util.http.fileupload.FileUploadBase.getItemIterator(FileUploadBase.java:256) ~[tomcat-embed-core-8.5.32.jar:8.5.32]
at org.apache.tomcat.util.http.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:280) ~[tomcat-embed-core-8.5.32.jar:8.5.32]
at org.apache.catalina.connector.Request.parseParts(Request.java:2884) ~[tomcat-embed-core-8.5.32.jar:8.5.32]
at org.apache.catalina.connector.Request.parseParameters(Request.java:3232) ~[tomcat-embed-core-8.5.32.jar:8.5.32]
It looks like you're not specifying a boundary in your HTTP request header - see here for what I mean Unable to send a multipart/mixed request to spring MVC based REST service
Content-Type: multipart/mixed;boundary=YourBoundaryOfChoiceHere
For your eyes only, in java you might use :
String boundary = Long.toHexString(System.currentTimeMillis());
request.getHeaders().setContentType("multipart/form-data; boundary="+boundary);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With