title: How to call MultipartFile Spring REST URL with RestTemplate
body: <p>When I try to call following MultipartFile Spring REST url with my Spring Template base Test method, I got following exception. How can I make this correct. Thanks. </p>
  
  <p><strong>Spring REST URL:</strong></p>
  
  <pre><code> @RequestMapping(value = "/media/uploadMultipartFile/{token}/{title}/{trailId}/{wpId}", method = RequestMethod.POST)
   public @ResponseBody MediaHttp uploadMultipartFile(@RequestParam MultipartFile file,
                                                      @PathVariable String token,
                                                      @PathVariable String title,
                                                      @PathVariable String trailId,
                                                      @PathVariable String wpId,
                                                      HttpServletResponse response)
  </code></pre>
  
  <p><strong>Test method:</strong></p>
  
  <pre><code>try {
  
          // Message Converters
          List&lt;HttpMessageConverter&lt;?&gt;&gt; messageConverters = new ArrayList&lt;HttpMessageConverter&lt;?&gt;&gt;();
          messageConverters.add(new FormHttpMessageConverter());
          messageConverters.add(new SourceHttpMessageConverter&lt;Source&gt;());
          messageConverters.add(new StringHttpMessageConverter());
          messageConverters.add(new MappingJacksonHttpMessageConverter());
  
          // RestTemplate
          RestTemplate template = new RestTemplate();
          template.setMessageConverters(messageConverters);
  
          // URL Parameters
          MultiValueMap&lt;String, Object&gt; parts = new LinkedMultiValueMap&lt;String, Object&gt;();
          parts.add("token", "nkc2jvbrbc");
          parts.add("title", "test mp4 file");
          parts.add("trailId", "2");
          parts.add("wpId", "7");
          parts.add("file", new FileSystemResource("C:\\Users\\Public\\Pictures\\Sample Pictures\\test.mp4"));
  
          // Post
          MediaHttp result = template.postForObject(Constants.APPLICATION_URL + "/media/uploadMultipartFile/{token}/{title}/{trailId}/{wpId}", parts, MediaHttp.class);
  
      } catch (Exception e) {
          System.out.println("Error: " + e.getMessage());
      }
  </code></pre>
  
  <p><strong>Exception:</strong> </p>
  
  <p>Invalid amount of variables values in [<a href="http://test.com:8080/DMW-skeleton-1.0/media/uploadMultipartFile/" rel="nofollow">http://test.com:8080/DMW-skeleton-1.0/media/uploadMultipartFile/</a>{token}/{title}/{trailId}/{wpId}]: expected 4; got 0</p>