Spring File Upload - 'Required request part is not present' : <p>I am trying to send POST request to my controller but cannot pass any parameter in any type unless I decide to use JSON. My goal is to pass a String and a file to my controller but I keep getting <code>Required request part 'xxx' is not present</code> error.</p>

<pre><code>@RestController
public class ConfigurationController {
    @PostMapping(value = "/config")
    public ResponseEntity&lt;?&gt; saveEnvironmentConfig(@RequestParam("file") MultipartFile uploadfile){
        return ResponseEntity.ok().body(null);
    }
}
</code></pre>

<p>I cannot have file here. Similarly if I try:</p>

<pre><code>@RestController
public class ConfigurationController {
    @PostMapping(value = "/config")
    public ResponseEntity&lt;?&gt; saveEnvironmentConfig(@RequestParam("name") String name){
        return ResponseEntity.ok().body(null);
    }
}
</code></pre>

<p>same thing I cannot get name here. </p>

<p>I am sending request via Postman as given in following screenshot:</p>

<p><a href="https://i.stack.imgur.com/gorVP.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gorVP.png" alt="Postman Request"></a></p>

<p><a href="https://i.stack.imgur.com/DYp6L.png" rel="noreferrer"><img src="https://i.stack.imgur.com/DYp6L.png" alt="Postman Request 2"></a></p>

<p>The only header tag is for Authorization. I do not have any Content-Type header, I tried to add <code>multipart/form-data</code> but did not help.</p>

<p>Only way I could pass String parameter is by adding to URL. So following <code>http://localhost:8080/SearchBox/admin/config?name=test</code> works but this is not what I want. I want String and File parameters in Body part. </p>

<p>I also tested via CURL:</p>

<pre><code>curl -X POST -H "Authorization:Bearer myToken" -H "Content-Type:Multipart/form-data" http://localhost:8080/SearchBox/admin/config --data 'pwd=pwd'
curl -X POST -H "Authorization:Bearer myToken"http://localhost:8080/SearchBox/admin/config --data 'pwd=pwd'
curl -H "Authorization:Bearer myToken" -F file=@"/g123.conf" http://localhost:8080/SearchBox/admin/config
</code></pre>

<p><strong>Note:</strong> I checked similar posts already but did not help
<a href="https://stackoverflow.com/questions/43936372/upload-file-springboot-required-request-part-file-is-not-present">This</a>, <a href="https://stackoverflow.com/questions/40488585/postman-required-request-part-file-is-not-present">This</a>, <a href="https://stackoverflow.com/questions/27101931/required-multipartfile-parameter-file-is-not-present-in-spring-mvc">This</a></p>
