2
votes

I am starting to use Spring WebClient to send requests to external services. One of those services, not under my control, responds in Json, but has the Content-Type "text" in the response headers.

status: 200
server: nginx/1.12.2
date: Tue, 13 Nov 2018 01:48:23 GMT
content-type: text

This makes the WebClient fail with the following exception when I call either bodyToMono(String.class) or toEntity(String.class):

Caused by: org.springframework.util.InvalidMimeTypeException: Invalid mime type "text": does not contain '/'

I am trying to see my options here, and I see none. I am not able to change the header on the fly (I saw this post: Reactive WebClient GET Request with text/html response but it does not work) I am not able to make WebClient accept a mime-type that has no /.

Can anybody help?

1

1 Answers

-2
votes

As a consumer, I am able to receive a String response at my Java Client using Spring WebClient for a content type: text/javascript provided by the producer.

If you are the producer of the service that sends the content-type as text, it is recommended to have it send content type in proper format.

Eg: application/json, application/pdf, text/javascript