[comixed-dev] Re: Stuck on a WebClient issue

  • From: Frédéric Fouret <fouretfrederic@xxxxxxxxx>
  • To: comixed-dev@xxxxxxxxxxxxx
  • Date: Wed, 15 Jul 2020 17:18:12 +0200

I think I've encountered this problem before at work. I'll look at the code
and see if I can remember the reason and the solution.

Le mer. 15 juil. 2020 à 14:52, Darryl L. Pierce <mcpierce@xxxxxxxxx> a
écrit :

I posted my question on StackOverflow [1] if anybody's interested in
following it and any possible answer.

[1]
https://stackoverflow.com/questions/62915284/spring-webclient-not-processing-json-content

On Wed, Jul 15, 2020 at 7:00 AM Darryl L. Pierce <mcpierce@xxxxxxxxx>
wrote:

I'm working on #301 right now (refactoring scraping to make it
extensible) and am hitting a brick wall I hope someone else has solved.

i've changed the code to use WebClient instances to fetch the JSON from
ComicVine. But, for some odd reason, after working for a few days, the code
has stopped working. Instead it now gives this error whenever it receives a
response from CV:

Caused by:
org.springframework.web.reactive.function.UnsupportedMediaTypeException:
Content type 'application/json' not supported for
bodyType=org.comixed.scrapers.comicvine.model.ComicVineIssuesQueryResponse
at
org.springframework.web.reactive.function.BodyExtractors.lambda$readWithMessageReaders$12(BodyExtractors.java:201)
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Error has been observed at the following site(s):

Which is very odd since the WebClient is told explicitly to accept JSON:

  protected WebClient createWebClient(final String url) {
    log.debug("Creating web client: url={}", url);
    return WebClient.builder()
        .baseUrl(url)
        .defaultHeaders(
            headers -> {
              headers.add(HttpHeaders.ACCEPT,
MediaType.APPLICATION_JSON_VALUE);
              headers.add(HttpHeaders.USER_AGENT, "ComiXed/0.7");
            })
        .build();
  }

Anybody have any insight on why this would fail? Especially since, as I
mentioned, it was working just fine, wasn't changed, then just stopped
working at all.

--
Darryl L. Pierce <mcpierce@xxxxxxxxx>
"Le centre du monde est partout." - Blaise Pascal
"Let's try and find some point of transcendence and leap together." -
Gord Downie



--
Darryl L. Pierce <mcpierce@xxxxxxxxx>
"Le centre du monde est partout." - Blaise Pascal
"Let's try and find some point of transcendence and leap together." - Gord
Downie

Other related posts: