Dear all,

First of all, I hope everything is fine and all of you are staying healthy!

When I read again the docs about Content Negotiation in RestXQ I noticed the sentence:

Functions can be restricted to specific Media Types. The default type is */*.

So I wrote the two RestXQ signaures [1] with the expectation of fallback() behaving as a catch-all for mime-types not declared in specific().

At that point, when calling the service with something stating "Content-Type: application/xml" BaseX yields the following error:

Stopped at /....:
[basex:restxq] Several functions found for path "test":
- ccp_ui:test [text/plain]
- ccp_ui:test2 [text/plain]

If I specify an explicit %rest:consumes("*/*") in the annotations of fallback(), specific() correctly intercepts the request.

Unfortunately at that point calling with "Content-Type: text/plain" which should slip through the functions and be catched by fallback() yields instead:

No function found that matches the request.

So there is no combination, to my knowledge, to implement my use-case correctly ... besides handling mime-types explicitly in code (which is rather uncomfortable).

I'm using BaseX 9.4.5 at the moment.

Do you have any hint on this?

Thank you very much.

Marco.

[1]

declare
  %rest:path("test")
  %rest:POST("{$body}")
  %rest:consumes("text/csv", "application/xml", "application/json")
  %output:method("text")
function s:specific($body as document-node()) {
   "Treated as document"
};

declare
  %rest:path("test")
  %rest:POST("{$body}")
  %output:method("text")
function s:fallback($body as item()) {
   "Treated as binary"
};