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