Created
February 6, 2018 16:06
-
-
Save rhari991/35bf23fa7f0f86e79b3b07db4a43dd0c to your computer and use it in GitHub Desktop.
Sample usage of @fieldmap option for the Retrofit library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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