parsing error using the new http-client in BaseX 10.x http module

Wednesday, 7 December 2022 · 2 messages
AN
Andreas Hengsbach | nexoma7 Dec 2022 11:55 #

Hi all,

it seems that the new http client in basex 10.x behaves differently when evaluating the response.

If, for example, an API that usually delivers JSON then delivers an HTML page on a 404, I run into a parser problem.

[experr:HC0002] Conversion failed: Stopped at ., 1/1: [json:parse] (1:1): Unexpected JSON value: '<br />...'.

The error page is correctly delivered with content type "text/html".

How is it decided which parser to use?

I would have expected the content type of the response to be used.

Has anyone else observed this behaviour?

This is how I used the http module:

let $response := http:send-request(<http:request method='post' ><http:body
media-type='application/json'/></http:request>, fn:concat($host, $apiKey),
$body)

return

(

(: do someting :)

)

The problem definitely does not occur with BaseX 9.x.

Many thanks and best regards

Andreas

AN
Andreas Hengsbach | nexoma7 Dec 2022 13:49 #

Sorry, it was a simple dependency problem. I forgot to include tagsoup.

Best regards

Andreas


⚡Generated with XQuery