title: Spring boot and Android Retrofit 2.0 , file upload with json data
body: <p>I have a REST API written using Spring boot and i am trying to POST an image and json data through Android client/app where i am using retrofit 2.0 . While doing that , i can see the data appearing but image file is showing as NULL.
  can you please help me how to do this or let me know where i am doing the mistake</p>
  
  <p>Server side REST Controller :</p>
  
  <pre><code>@RequestMapping(value = "/v1/producttest", method = RequestMethod.POST) 
  @ResponseStatus(HttpStatus.CREATED)
  public @ResponseBody ProductTestResponse create( @Valid String producttestEntry,
      @RequestPart(value = "file", required = false) MultipartFile file) {
      LOGGER.info("Creating a product test: {}", producttestEntry);
      ObjectMapper mapper = new ObjectMapper();
      Map&lt;String, Object&gt; map;
      try {
          map = mapper.readValue(productbuyerEntry, Map.class);
      } catch (JsonParseException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      } catch (JsonMappingException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  </code></pre>
  
  <p>Android Side code:</p>
  
  <pre><code> MultipartBody.Part reqFile = MultipartBody.Part.createFormData("file", finalFile.getName(), RequestBody.create(okhttp3.MediaType.parse("multipart/form-data"), finalFile));
      Call &lt;PostTestresponse&gt; cal = restInterface.Posttest(hj, reqFile);
  </code></pre>