title: Error uploading a file using Retrofit 2
body: <p>I'm trying to upload a file (picture) to the server using <code>Retrofit 2</code>. I'm following that <a href="https://futurestud.io/blog/retrofit-2-how-to-upload-files-to-server" rel="noreferrer">tutorial</a> which seems pretty easy at first, but didn't work in my case... </p>
  
  <p>When I call the API function, i'm always getting this error:</p>
  
  <pre><code>W/System.err: java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
  W/System.err:     at retrofit2.ServiceMethod$Builder.build(ServiceMethod.java:190)
  W/System.err:     at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:166)
  W/System.err:     at retrofit2.Retrofit$1.invoke(Retrofit.java:145)
  W/System.err:     at java.lang.reflect.Proxy.invoke(Proxy.java:393)
  W/System.err:     at com.plante.android.cobalt.fragment.FragmentIncidentPlan.uploadFile(FragmentIncidentPlan.java:575)
  </code></pre>
  
  <p><em>Here is my API call:</em></p>
  
  <pre><code>@Multipart
  @POST(Constants.URL_UPLOAD)
  Call&lt;ResponseBody&gt; upload(@Part RequestBody description,
                            @Part MultipartBody.Part file);
  </code></pre>
  
  <p><em>Here is the method I use to upload a file:</em></p>
  
  <pre><code>private void uploadFile(String path) {
      // create upload service client
  
      // use the FileUtils to get the actual file by uri
      File file = new File(path);
      Log.e(TAG, file.getAbsolutePath());
  
      // create RequestBody instance from file
      RequestBody requestFile =
              RequestBody.create(MediaType.parse("multipart/form-data"), file);
  
      // MultipartBody.Part is used to send also the actual file name
      MultipartBody.Part body =
              MultipartBody.Part.createFormData("picture", file.getName(), requestFile);
  
      // add another part within the multipart request
      String descriptionString = "hello, this is description speaking";
      RequestBody description =
              RequestBody.create(
                      MediaType.parse("multipart/form-data"), descriptionString);
  
      // finally, execute the request
      Call&lt;ResponseBody&gt; call = cobaltServices.upload(description, body);
      call.enqueue(new Callback&lt;ResponseBody&gt;() {
          @Override
          public void onResponse(Call&lt;ResponseBody&gt; call,
                                 Response&lt;ResponseBody&gt; response) {
              Log.v("Upload", "success");
          }
  
          @Override
          public void onFailure(Call&lt;ResponseBody&gt; call, Throwable t) {
              Log.e("Upload error:", t.getMessage());
          }
      });
  }
  </code></pre>