Fuel get the body response on error

As it is mentioned in this issue. You can receive the body with response.data, which returns ByteArray. Therefore the code could look something like this:

val myBody = String(response.data)

Another solution would be, disabling the HTTP Code validator, which can be achieved with: FuelManager.removeAllResponseInterceptors()


if your code uses awaitByteArrayResponse and got Result<?, FuelError>> or FuelError object, try this: val (content, error) = result // Result<?, FuelError>> val strContent = error.errorData.toString(Charsets.UTF_8)

Tags:

Android

Kotlin