https://kotlinlang.org logo
#ktor
Title
# ktor
r

rsetkus

02/08/2021, 1:31 AM
Hi, What is correct way of handling empty response? When executing
PUT
request, api returns an empty body response but all types of ktor requests have a return type. To satisfy it, have created an empty data class, however getting an error when executing such request:
io.ktor.client.call.NoTransformationFoundException: No transformation found: class <http://io.ktor.utils.io|io.ktor.utils.io>.ByteBufferChannel (Kotlin reflection is not available) -> class xx.yy.api.NoContent (Kotlin reflection is not available)
. I’d guess serialization process is confused when mapping an empty response to data class. Any ideas how to fix it?
r

Rustam Siniukov

02/08/2021, 11:51 AM
you can use
client.put<Unit>(url)
r

rsetkus

02/08/2021, 8:22 PM
Thanks @Rustam Siniukov. Seems it worked out.
👍 1
12 Views