Mike R
07/29/2019, 11:00 PMthis.rfBuilder.apply {
baseUrl(BASE_URL)
addConverterFactory(
GsonConverterFactory.create(
GsonBuilder().apply {
registerTypeAdapter(SearchQuery::class.java, SearchQueryAdapter())
excludeFieldsWithoutExposeAnnotation()
setPrettyPrinting()
}.create()
)
)
client(
OkHttpClient.Builder().apply {
addInterceptor { chain ->
val original = chain.request()
val requestBuilder = original.newBuilder().addHeader("User-Agent", USER_AGENT)
val request = requestBuilder.build()
chain.proceed(request)
}
}.build()
)
}
I've created a SearchQueryAdapter that implements JsonSerializer
and the serialize
function.
This is my function declaration in my Retrofit service:
@GET("posts")
fun searchListings(
@Query("request") searchQuery: SearchQuery,
@Query("count") count: Int = 50,
@Query("max_id") maxId: Int = 1
): Call<GetListingsResponse>
What's happening is that the query parameter for searchQuery doesn't serialize in that the value of the parameter becomes SearchQuery( <serialized content here>)
, which isn't valid for the API. What am I doing wrong here?gildor
07/30/2019, 2:18 AMMike R
07/30/2019, 2:21 AMMike R
07/30/2019, 2:21 AM