Latest
HTTP Client
Java 11
I get the following error:
Caused by: io.ktor.client.call.NoTransformationFoundException: No transformation found: class io.ktor.client.features.observer.DelegatedResponse -> class com.flexshopper.kraken.geolocation.search.retailers.RetailerFetchResult
And I'm not sure what I'm doing wrong... I seem to have followed the example, right?
data class TiresVendor(
val vendorName: String,
var street1: String,
val street2: String?,
val city: String,
val region: String,
val zip: String,
val displayName: String = vendorName.replace(Regex("(.+?)(NTB|MDT|TBC)"), "$2 #$1")
)
@JsonIgnoreProperties("_links")
class RetailerFetchResult<T>(
private val pageCount: Int,
private val pageSize: Int,
private val totalItems: Int,
private val page: Int
) {
private lateinit var vendors: List<T>
@JsonProperty("_embedded")
fun parseTireRetailers(retailers: Map<String, List<T>>) {
vendors = retailers["tire-retailers"]!!
}
override fun toString(): String {
return "RetailerFetchResult(pageCount=$pageCount, " +
"pageSize=$pageSize, totalItems=$totalItems, page=$page, vendors=$vendors)"
}
}
class TireRetailersFetcher(private val baseUrl: String) {
suspend fun fetch(): RetailerFetchResult<TiresVendor> {
val client = HttpClient {
install(JsonFeature) {
serializer = JacksonSerializer {
}
}
install(Logging) {
level = LogLevel.HEADERS
}
}
return client.get(baseUrl) {
contentType(ContentType.Application.Json)
}
}
}
Needed to specify accept(ContentType.Application.Json) manually.
Most helpful comment
Needed to specify
accept(ContentType.Application.Json)manually.