Hi Marco,
Sorry for letting you wait. Specializations of the json mimetype will now be detected as well [1,2].
Cheers, Christian
[1] https://github.com/BaseXdb/basex/commit/a18a092b11a5240075b081ffd301014f0dc0... [2] http://files.basex.org/releases/latest/
On Tue, Jan 15, 2019 at 11:35 AM Marco Lettere m.lettere@gmail.com wrote:
Hi all, we have to deal with a third-party REST service which in case of error conditions returns this mime type: application/problem+json; charset=utf-8.
I wrote this RestXQ [1] to mock it. Just copy it into restxq.xqm...
When I call it like [2] I get [XPTY0004] Cannot convert xs:base64Binary to xs:string: "IntcImFcIjpcImJcIn0i". This is because the response is seen as a binary and this can be double checked calling with [3]. I felt (maybe wrongly) that specializations of the mimetype had been faced in BaseX implementation of http:request somewhere back in time but I couldn't find anything in the mail archives.
The strange thing however is that I get the same error when calling like [4] with override-mime-type set to text/json or application/json which instead I was expecting to work.
Is the behaviour in this scenario expected or does this hide some inconsistency?
Thanks, as usual, for the support.
Regards,
Marco.
[1] declare%rest:path("mc/dummy") %rest:GET %output:method("json") function page:dummy() { rest:response <http:response status="400"> <http:header name="Content-Type" value="application/problem+json; charset=utf-8"/> </http:response> </rest:response>, '{"a":"b"}' };
[2] json:parse( http:send-request(<http:request method="get"/>,"http://localhost:8984/mc/dummy%22)%5B2] )
[3] json:parse( convert:binary-to-string( http:send-request(<http:request method="get"/>,"http://localhost:8984/mc/dummy%22)%5B2] ) )
[4] json:parse( http:send-request(<http:request method="get" override-media-type="application/json"/>,"http://localhost:8984/mc/dummy%22)%5B2] )