When you call restful API with Retrofit, sometimes there are query arguments which are JSON objects you should provide.
The json format string contains characters which cannot be used in a URL such as quotation, comma …
Then we have to do encoding on the JSON objects to fit URL format.
First of all, you got an API contract:
We need to get cards of a user based on a filter. The query argument which marked as @Query would appear in the request URL. But it’s not a builtin type such as int, String …
It’s a Java object which would be turned in to a JSON string then pass to the request URL. So we have to encode it.
Then add the EncodingGsonConverterFactory to your Retrofit instance.