简体   繁体   中英

Postman - Required MultipartFile parameter 'file' is not present

I'm trying to call a post method with postman version 5.3.1 but I got the following error: "Required MultipartFile parameter 'file' is not present". I tried disabling the "Content-Type" Headers. I attached the file in the body section, selecting the form-data option and putting "file" on key input field.

I'm looking this post jQuery Ajax file upload: Required MultipartFile parameter 'file' is not present too but I cannot get a solution.

I will try to answer, I might be wrong if I am misunderstanding the issue. In postman you should adjust the header as multipart/from-data, do this in order to upload a file using an endpoint.

This will be done here:

在此输入图像描述

and here:

在此输入图像描述

在此输入图像描述

I really hope this helps, if not let me know, with more detail about the issue

===EDIT===

We are in a good path. You are receiving a "The request was rejected because no multipart boundary was found", and that is because your app need to split the "Multipart" being sent, and your application is complaining that it wasn't able to separate the data because it wasn't able to find its boundary, please read rfc1341 - 7.2.1 Multipart: The common syntax , where they explain about how boundairs work.

Now please try adding a boundary to the call. ie

Content-Type: multipart/form-data; 
          boundary=gc0p4Jq0M2Yt08jU534c0p

在此输入图像描述

You will find the explanation on the documentation, on my test bed it worked, I hope this works for you (if not can you please provide the code example of you server endpoint).

For Springboot: If your application does not use spring-boot-starter-web and spring-boot-starter-data-rest, instead it uses "spring-boot-starter-webflux", then you will get the error "HTTP Status 400 - Required MultipartFile parameter 'file' is not present" when you use "@RequestParam("file") MultipartFile file" in your POST request.

Since webflux is a reactive library, MultipartFile is not supported.

You need to follow this link for reactive-programming way to upload form-data. https://github.com/entzik/reactive-spring-boot-examples/blob/master/src/main/java/com/thekirschners/springbootsamples/reactiveupload/ReactiveUploadResource.java

I have tried a lot. For webflux only application, the above solution alone works.

In your POSTMAN request, you need not add anything in the header. Just upload the file as form-data in the BODY. It should work fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM