@Documented
@Target(value=PARAMETER)
@Retention(value=RUNTIME)
public @interface Field
Values are converted to strings using Retrofit.stringConverter(Type, Annotation[])
(or
Object.toString()
, if no matching string converter is installed) and then form URL
encoded. null
values are ignored. Passing a List
or array will
result in a field pair for each non-null
item.
Simple Example:
@FormUrlEncoded
@POST("/")
Call<ResponseBody> example(
@Field("name") String name,
@Field("occupation") String occupation);
Calling with foo.example("Bob Smith", "President")
yields a request body of name=Bob+Smith&occupation=President
.
Array/Varargs Example:
@FormUrlEncoded
@POST("/list")
Call<ResponseBody> example(@Field("name") String... names);
Calling with foo.example("Bob Smith", "Jane Doe")
yields a request body of name=Bob+Smith&name=Jane+Doe
.FormUrlEncoded
,
FieldMap
public abstract boolean encoded