When using Retrofit, I know you can use @FieldMap Map<String, String> options
to specify optional queries.
Say that I have a api call that had 2 required fields and 3 optional fields.
How would I format these calls?
Would it be something like
Call<Response> getStuff(@Query("user_id") String userId, @Query("password") String password, @FieldMap Map<String, String> options)
or would the entire thing be a single @FieldMap like:
Call<Response> getStuff(@FieldMap Map<String, String> options)
and with this option would you just fill in the required fields and then use null
for the optionals?
@FieldMap
and @Query
params both support optional fields. As you mentioned, simply pass null
if you don't want to pass a value.