Annotation Interface Multipart


REST proxy method-level multipart/form-data marker annotation.

Marks a Remote-proxy method whose request body is a multipart/form-data message (RFC 7578) assembled from the method's @Part-annotated parameters — the Retrofit @Multipart pattern. Each @Part parameter contributes one part (a text field, a file/stream/byte-array upload, or a serialized bean); the engine adapts those parameters into the streaming MultipartBody and the multipart/form-data Content-Type (with its generated boundary) is applied automatically.

Example:

@Remote(path="/api") public interface UploadService { @RemotePost("/upload") @Multipart String upload( @Part("title") String title, @Part(name="attachment", contentType="application/pdf") File report); }

Body-mode exclusivity:

A method is either multipart (@Multipart + one or more @Part parameters) or single-body (@Content), never both. Declaring both on the same method — or declaring @Multipart with no @Part parameters, or a @Part parameter without @Multipart — is rejected at proxy-build time with an IllegalArgumentException.

Notes:
  • Escape hatch (Option B): for advanced cases you can still hand-assemble a MultipartBody and pass it as a single @Content body without @Multipart; that path is unchanged.
  • Honored by the next-generation engine (RestClient.remote(...)) only; the classic engine currently ignores this annotation.
See Also:
Since:
9.2.1