Retrofit - Multipart request: Required MultipartFile parameter 'file' is not present
<p>I'm trying to send file on server using Retrofit2.
I do everything according documentation, but always get 400 server error.</p>

<p>I'm tried to do like this:</p>

<pre><code>RequestBody body =
                RequestBody.create(MediaType.parse("image/png"), photo);
    //..........

    @Multipart
    @POST(ADD_PHOTO)
    Observable&lt;HPSPhotoResponse&gt;
    addPhoto(@Part("file") RequestBody file);
</code></pre>

<p>...and like this:</p>

<pre><code>MultipartBody.Part part = MultipartBody.Part.createFormData("file", "file", body);
     //...........

    @Multipart
    @POST(ADD_PHOTO)
    Observable&lt;HPSPhotoResponse&gt;
    addPhoto(@Part("file") MultipartBody.Part files);
</code></pre>

<p>does't matter. Result is always the same "Multipart request: Required MultipartFile parameter 'file' is not present" - server response.</p>

<p>I would think that Spring on the server works not good but I do the equivalent code on Swift (iOS) and it works! Here Server sees this 'file' part.</p>

<pre><code>Alamofire.upload(method, endpoint, headers: headers,
            multipartFormData: { multipartFormData in
                multipartFormData.appendBodyPart(fileURL: self.filePath!, name: "file")
            }
</code></pre>

<p>Now I want it works on Android with Retrofit.
But I even look in logs of Retrofit requests and indeed I don't see any 'file' text in the logs.</p>

<p>What's wrong with that?</p>