-
Notifications
You must be signed in to change notification settings - Fork 71
Form url encoded
Orhan Obut edited this page Aug 9, 2015
·
1 revision
Use @Field annotation to provide key-value pairs
@FormUrlEncoded
@POST("/users/repos")
void fetchRepoBySearch(
@Field("page") int pageNumber,
@Field("sort") String sort,
Callback<Repo> callback
);
service.fetchRepoBySearch(2,"asc", callback);
//output url is ENDPOINT/users/repos?page=2&sort=asc
@FieldMap is used to add fields by map
@FormUrlEncoded
@POST("/users/repos")
void fetchRepoBySearch(
@FieldMap Map queryParamsMap,
Callback<Repo> callback
);
Map<String,String> map = new HashMap<>();
map.put("sort","asc");
map.put("offset", "100");
service.fetchRepoBySearch(map, callback);
All contributes are welcome.