df
11/17/2020, 5:08 PMval content = """
{"identifier":"cdp_9055274"}
{"identifier":"cdp_9111757"}
{"identifier":"cdp_9135021"}
""".trimIndent()
val response = httpClient.patch<String> {
url("/api/rest/v1/products")
header("Authorization", "Bearer ${token.accessToken}")
contentType(ContentType("application", "vnd.akeneo.collection+json"))
body = content
}
and it seems like regardless of what I'm writing into the body (the string, TextContent / ByteArrayContent), the body is always serialized into json again.marstran
11/17/2020, 5:22 PMhttpClient
defined?
Maybe you can try with a client where the JSON-feature isn't installed.df
11/17/2020, 5:23 PMfun httpClient(objectMapper: ObjectMapper, settings: AkeneoClientSettings): HttpClient {
return HttpClient(CIO) {
defaultRequest {
url {
host = settings.host
protocol = URLProtocol.HTTPS
}
}
install(JsonFeature) {
serializer = JacksonSerializer(objectMapper) {
propertyNamingStrategy = PropertyNamingStrategy.SNAKE_CASE
}
}
install(Logging) {
logger = Logger.SIMPLE
level = LogLevel.ALL
}
expectSuccess = false
}
}
value.startsWith("application/") && value.endsWith("+json")
marstran
11/17/2020, 5:29 PMtext/plain
?df
11/17/2020, 5:30 PMmarstran
11/17/2020, 5:31 PMdf
11/17/2020, 5:31 PMContent-type • Equal to 'application/vnd.akeneo.collection+json', no other value allowed
marstran
11/17/2020, 5:31 PMdf
11/17/2020, 5:31 PMmarstran
11/17/2020, 5:32 PMdf
11/17/2020, 5:33 PMHttpClient: CONTENT HEADERS
HttpClient: BODY Content-Type: application/vnd.akeneo.collection+json
HttpClient: BODY START
HttpClient: "{\"identifier\":\"cdp_9055274\"}\n{\"identifier\":\"cdp_9111757\"}\n{\"identifier\":\"cdp_9135021\"}"
install(JsonFeature) {
serializer = JacksonSerializer(objectMapper) {
propertyNamingStrategy = PropertyNamingStrategy.SNAKE_CASE
receiveContentTypeMatchers = listOf(
object : ContentTypeMatcher {
override fun contains(contentType: ContentType): Boolean {
return ContentType.Application.Json.match(contentType)
}
}
)
}
}
Rustam Siniukov
11/17/2020, 6:32 PMval response = httpClient.patch<String> {
url("/api/rest/v1/products")
header("Authorization", "Bearer ${token.accessToken}")
body = TextContent(content, ContentType("application", "vnd.akeneo.collection+json"))
}
df
11/18/2020, 9:17 PMRustam Siniukov
11/23/2020, 1:28 PMdf
11/23/2020, 7:42 PMRustam Siniukov
11/23/2020, 7:50 PMContentType
in header, only in TextContent
.
But I think that maybe it makes sense to skip serialization for all children of OutgoingContent
. Ticket will be helpful ti think about usecases and agree on the solution