Raed Ghazal
11/03/2024, 8:24 PMMultiPartFormDataContent
here is my code
val body = MultiPartFormDataContent(
parts = formData {
append("images", request.image, Headers.build {
append(HttpHeaders.ContentType, "image/png")
append(HttpHeaders.ContentDisposition, "filename=\"name.png\"")
})
request.items.forEachIndexed { index, item ->
append("items[$index]", Json.encodeToString(item), Headers.build {
append(HttpHeaders.ContentType, "application/json")
})
}
}
)
runCatchingAllowingCoroutineCancellation {
<http://httpClient.post|httpClient.post>("receipts") {
expectSuccess = true
contentType(ContentType.MultiPart.FormData)
setBody(body)
}.body<Unit>()
}
Raed Ghazal
11/03/2024, 8:25 PMitems
)
if I encode the whole list together I get the second screenshot's resultRaed Ghazal
11/03/2024, 8:26 PMmultipart