I try to use upload image api on my mobile app. I have got api for this call like that
@POST("images/upload")
@Multipart
suspend fun uploadImage(
@Header("x-api-key") apiKey: String,
@Part("description") desc:String,
@Part body: MultipartBody.Part
): UploadCatResponse
Then I call this method in my class
class SendPhotoModel {
private val session = App.SessionStorage.getSession()
fun uploadPhoto(
file: File,
listener: (Int) -> Unit
) = flow {
session?.let {
val fileRequestBody =
MultipartBody.Part
.create(
file.asRequestBody("image/*".toMediaType())
)
emit(
Api.getApi().uploadImage(
App.ApiKeyProvider.getKey(),
it.userId,
fileRequestBody
)
)
}
}
}
And I get response " {“message”:“Cannot read property ‘name’ of undefined”,“status”:500,“level”:“info”}"
What’s the name? What should I do to skip this error?