I'm using Spring to integrate towards a third party API. This API validates the Content-Type header and requires it to be exactly
application/json;profile=https://se.digitalreceipts.net/schemas/json/retail/v1.0
The code below is the relevant part of the POST call i make towards the API.
webClient.post()
.uri("/dr/v1/receipts")
.attributes(clientRegistrationId(clientRegistrationId))
.header("Content-Type", "application/json;profile=https://se.digitalreceipts.net/schemas/json/retail/v1.0")
When executing this request an exception is thrown:
org.springframework.http.InvalidMediaTypeException: Invalid mime type "application/json;profile=https://se.digitalreceipts.net/schemas/json/retail/v1.0": Invalid token character ':' in token "https://se.digitalreceipts.net/schemas/json/retail/v1.0"
at org.springframework.http.MediaType.parseMediaType(MediaType.java:620) ~[spring-web-5.3.10.jar:5.3.10]
Seems that spring does not allow colons in the Content-Type header.
This is an issue as the API I'm integrating towards absolutely requires the content-type header to be exactly as previously specificated.
I can't for instance write the value with quotation marks
application/json;profile="https://se.digitalreceipts.net/schemas/json/retail/v1.0"
I'm looking for a solution where I can enter the required Content-Type header using Spring WebClient.