Hi I am trying to make multiform request with ktor but I am getting above error. How can I serilize MultiPartBody?
val body = MultipartBody.Builder().setType(MultipartBody.FORM)
.addFormDataPart("choice","John Wick")
.addFormDataPart("image",path,
File(path).asRequestBody("application/octet-stream".toMediaType()))
.build()
val httpResponse = client.post {
url("https://example.com")
setBody(body)
header("Content-Type","application/json")
header("Authorization", "Bearer key")
}
Ktor cannot send directly an object of the
okhttp3.MultipartBody
class. Please use theMultiPartFormDataContent
class instead: