title: Upload file in Retrofit 2
body: <p><a href="https://i.stack.imgur.com/ZDYkj.png*" rel="noreferrer"><img src="https://i.stack.imgur.com/ZDYkj.png*" alt="enter image description here"></a></p>
  
  <p>I tried the following but on response i am getting 500 error (Internal Server Error) -- help me design the interface for the request in the above screenshot...thanks</p>
  
  <pre><code>@Multipart
  @POST("myrecord")
  Call&lt;ResponseBody&gt; addRecord(@Query("token") String token,@Query("userid") int userId,
                               @Query("name") String name, @Part("file") RequestBody file);
  
  
  File file = new File(getRealPathFromURI(data.getData()));
  RequestBody requestFile = RequestBody.create(MediaType.parse("image/*"), getRealPathFromURI(data.getData()));` 
  Call&lt;ResponseBody&gt; responseBodyCall = service.addRecord(token, userId,
                  "newFileName", requestFile);
          responseBodyCall.enqueue(new Callback&lt;ResponseBody&gt;() {
              @Override
              public void onResponse(Call&lt;ResponseBody&gt; call, Response&lt;ResponseBody&gt; response) {
                  Log.d("Response", "="+response.code());
                  Log.d("Response", "= "+response.message());
  
              }
  
              @Override
              public void onFailure(Call&lt;ResponseBody&gt; call, Throwable t) {
                  Log.d("failure", "message = " + t.getMessage());
                  Log.d("failure", "cause = " + t.getCause());
              }
          });`
  </code></pre>