Annotation Interface Multipart
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 @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:
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
MultipartBodyand pass it as a single@Contentbody 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