Fuel.post("/user").body(prepareRegistrationData(registration)).responseJson { request, response, either -> info("Request=>"+request.toString()) info("Response=>"+response.toString()) when(either) { is Either.Left -> { info(either.left) val error: FuelError = either.get() //error code need to be printed } is Either.Right -> { info("Registraion Response=>${either.right}") val tinyDB = TinyDB(context) tinyDB.putString(NetVars.REGISTRATION.UNCONFIRMED_USER.name,registration.emailId) tinyDB.putLong(NetVars.REGISTRATION.EMAIL_SENT_TIMESTAMP.name,System.currentTimeMillis()) } } }