Skip to content

Instantly share code, notes, and snippets.

@rhari991
Created February 6, 2018 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rhari991/35bf23fa7f0f86e79b3b07db4a43dd0c to your computer and use it in GitHub Desktop.
Save rhari991/35bf23fa7f0f86e79b3b07db4a43dd0c to your computer and use it in GitHub Desktop.
Sample usage of @fieldmap option for the Retrofit library
public interface ApiService {
@FormUrlEncoded
@POST("/endpoint")
Call<ReturnType> method(@FieldMap Map<String, String> fields);
}
public void sampleUsage {
Map<String, String> map = new HashMap<>();
map.add(requiredParam1Name, requiredParam1Value);
map.add(optionalParam1Name, optionalParam1Value);
map.add(optionalParam2Name, optionalParam2Value);
Call<ReturnType> returnedObject = apiService.method(map);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment