Kamil K
04/01/2025, 5:59 PMorgans array[string] _(formData)
._
-H 'accept: application/json' \
-H 'Content-Type: multipart/form-data' \
-F 'images=@IMG_20250327_125636.jpg;type=image/jpeg' \
-F 'images=@IMG_20250327_125639.jpg;type=image/jpeg' \
-F 'organs=leaf' \
-F 'organs=auto'
I’ve arrived at this in ktor.
setBody(
MultiPartFormDataContent(
formData {
organTagWithImageAsBytes.entries.forEach { (tag, file) ->
append("images", file.readBytes(), Headers.build {
append(HttpHeaders.ContentType, ContentType.Image.JPEG)
append(HttpHeaders.ContentDisposition, "filename=\"${file.name}\"")
append("organs", tag)
})
}
}
)
)
In response I’ve receive default values of organs and not values that were sent. Where doing the call from swagger returns selected tag values. What’s the proper way of appending this data?Aleksei Tirman [JB]
04/02/2025, 8:38 AMappend("organs", tag)
within the Headers.build
block, which effectively adds the organs
header. To solve the problem, move the append("organs", tag)
call out of the block to append the form part.