My response is coming with status code 409 using the class method below under ApiResult.Failure.HttpFailure how can i get my response body. When i try to get the response it tells me the response is null.
ApiResult,Kotlin and Coroutines
This is the interface
suspend fun createBroom(
@Body body: CreateBroomPayload
): ApiResult<AddBroomResult, ErrorResult>
Api implemmentation
when (val result =
webServices.createBroom(
currentTask.taskId,
inputCustomerDetail.nationalId.toString(),
)) {
is ApiResult.Success -> {
with(result.value) {
broomData.value =
Broom(
NationalId.toString(),
IdType.toString(),
)
}
}
is ApiResult.Failure.HttpFailure -> {
with(result.error) {
when (this?.Errors?.get(0)?.ErrorId) {
"0054" -> {
addBroomResult.emit(Result.MyError(R.string.id_number_already_registered))
return@launch
}
"0039" -> {
addBroomResult.emit(Result.MyError(R.string.mobile_number_in_use))
return@launch
}
"0055" -> {
addBroomResult.emit(Result.MyError(R.string.email_address_in_use))
return@launch
}
else -> {
addBroomResult.emit(Result.MyError(R.string.errorNetwork))
return@launch
}
}
}
}
is ApiResult.Failure.ApiFailure -> {
with(result.error) {
when (this?.Errors?.get(0)?.ErrorId) {
"0054" -> {
addBroomResult.emit(Result.MyError(R.string.id_number_already_registered))
return@launch
}
"0039" -> {
addBroomResult.emit(Result.MyError(R.string.mobile_number_in_use))
return@launch
}
"0055" -> {
addBroomResult.emit(Result.MyError(R.string.email_address_in_use))
return@launch
}
else -> {
addBroomResult.emit(Result.MyError(R.string.errorNetwork))
return@launch
}
}
}
}