Hello Marco,
I can't really follow. What 400 status code are you talking about, because I can't really see one in the code. I couldn't really test it because I didn't manage to tell curl to send form data and using HEAD at the same time (something like curl -I -F message=yes ... didn't work, help appreciated).
But your if statement (returning the empty sequence) will result in the following error:
[BASX0003] HEAD method must return a single 'restxq:response' element.
Although I didn't test in in the combination, if I either use HEAD or the form param it worked. So could you please clarify in which case this code did work and what error you are experiencing?
Cheers, Dirk
On 11/04/14 16:34, Marco Lettere wrote:
I've the following simplified RESTXQ code snippet that I use with basex 7.8.
declare %rest:path("/exists") %rest:HEAD %rest:form-param("message","{$message}") function page:exist( $message as xs:string) {
try{ if ($message = 'yes') then () else error(xs:QName("err:ERR"), "Message wasn't yes!")
} catch * { rest:response <http:response status="404" reason="{$err:description}"> <http:header name="DBG" value="{'message was '|| $message}"/> </http:response> </rest:response> } };
This is always returning HTTP status 404 with reason "No function found that matches the request". This happens only for the 400 status code. Any other status code I use to set behaves as expected including 404 itself. Any hints? Thank you. Regards, Marco.