okaymak
11/19/2020, 7:30 PMclient.submitFormWithBinaryData {
url { encodedPath = "my_url" }
formData {
append("my_key", "my_key_value")
}
}
Bu then get an error from kotlinx serialization:
kotlinx.serialization.SerializationException: Serializer for class 'MultiPartFormDataContent' is not found.
What am I missing here?cy
11/20/2020, 11:56 AMokaymak
11/20/2020, 12:07 PMval client = HttpClient {
install(JsonFeature) {
serializer = KotlinxSerializer(jsonConfig)
}
install(DefaultRequest) {
if (url.host == "localhost") {
// Workaround to set a sort of a base url
url.host = "my_host"
url.protocol = URLProtocol.HTTPS
url.encodedPath = "my_path" + url.encodedPath
}
}
install(Logging) {
logger = Logger.SIMPLE
level = LogLevel.ALL
}
}
Ruslan A
11/24/2020, 1:17 PMAlexander Black
11/25/2020, 4:44 PMbody = MultiPartFormDataContent( param.toFormData())
Note my toFormData() method is a custom extension for my usecase.val response = client.submitForm<T> { contentType(ContentType.Application.Json)
method = <http://HttpMethod.Post|HttpMethod.Post>
url("$baseUrl$route")
if (param != null) {
if(param is JsonObject) body = MultiPartFormDataContent( param.toFormData())
}
}
Note I’m doing things in a kinda weird way with JsonObjects because I’m working towards migrating to a new API that will support JSON payloads, but currently my test/legacy API does not.