400 Bad Request with spring REST
<p>I have spring rest service such this</p>

<pre><code>@RequestMapping(method = RequestMethod.POST,
        path = "/getdata", consumes = {"multipart/form-data"}, produces =     MediaType.APPLICATION_JSON)
public
@ResponseBody
Result getBarcode(@RequestParam("text") String sl,
                  @RequestParam("imageFile") MultipartFile file)  {
                ... some logic
     return new Result(text, message, !processingError);
 }
</code></pre>

<p>When i call this from <strong>http</strong> form it works fine and return <strong>json text</strong>. But when i trying to call this from java code</p>

<pre><code>RestTemplate restTemplate = new RestTemplate();
    MultiValueMap&lt;String, Object&gt; map = new LinkedMultiValueMap&lt;&gt;();
    map.add("text", "123");
    map.add("imageFile", new File("...path to file..."));
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.MULTIPART_FORM_DATA);
      headers.setAccept(MediaType.parseMediaTypes("application/json,text/html,application/xhtml+xml,application/xml"));
    HttpEntity&lt;MultiValueMap&lt;String, Object&gt;&gt; requestEntity = new  HttpEntity&lt;&gt;(map, headers);
    ResponseEntity&lt;BcResult&gt; response = restTemplate.exchange("http://localhost:8080/getdata", HttpMethod.POST, requestEntity, BcResult.class);
</code></pre>

<p>Then i am getting <strong>400 Bad request error</strong>. Can`t figure out what is wrong with this code...</p>