Hi Marco,
Thanks! Yes now it works. The problem was that I did not use the variable in POST but in the form/query-param.
Thanks! Joseph
Il giorno 15/nov/2015, alle ore 20:47, Marco Lettere marco.lettere@dedalus.eu ha scritto:
Hi, mmhhh.. it's strange.
I tried the following which just replaces the href with one that makes sense on my PC:
http:send-request( <http:request method="POST" href="http://localhost:8984/test%22%3E <http:body media-type="text/plain">My text is long</http:body> </http:request> )
and added this restxq to my server's restxq,xqm:
declare %rest:path('test') %rest:POST('{$body}') %rest:consumes("text/plain") function page:T($body as xs:string) { <a>{$body}</a> };
and when running the above request I get this response. Which looks correct.
<http:response xmlns:http="http://expath.org/ns/http-client" status="200" message="OK"> <http:header name="Content-Length" value="22"/> <http:header name="Content-Type" value="application/xml; charset=UTF-8"/> <http:header name="Server" value="Jetty(8.1.16.v20140903)"/> <http:body media-type="application/xml"/> </http:response> <a>My text is long</a>
Hope this helps you out. Regards, M.
________________________________________ From: meumapple@gmail.com meumapple@gmail.com Sent: Sunday, November 15, 2015 11:51 AM To: Marco Lettere Cc: BaseX Subject: Re: [basex-talk] Restxq
Hi Marco,
Thanks. I knew that page but the function does not work. The variable is not passed, whether I write exactly what you write or I specify "text=my text is long" ("text" is the name of the variable in the restxq function).
Thanks, J.
Il giorno 15/nov/2015, alle ore 10:19, Marco Lettere marco.lettere@dedalus.eu ha scritto:
Hi, look at [1]. This is the documentation of the http client available in BaseX following eXpath specification in [2]. Your request in particularly should look like:
http:send-request(<http:request method="POST"/>, "http://address", "my text is long")
or more declaratively:
http:send-request( <http:request method="POST" href="http://address%22%3E <http:body media-type="text/plain">My text is long</http:body> </http:request> )
BR, Marco.
[1] http://docs.basex.org/wiki/HTTP_Module#http:send-request [2] http://expath.org/spec/http-client ________________________________________ From: basex-talk-bounces@mailman.uni-konstanz.de basex-talk-bounces@mailman.uni-konstanz.de on behalf of meumapple meumapple@gmail.com Sent: Saturday, November 14, 2015 10:51 PM To: BaseX Subject: [basex-talk] Restxq
Hi All,
I am using restxq. I wrote a function which takes one variable (this should be a chunk of text, not a single word). The output is xml.
I can have the function work if I pass the content of the variable with
curl -X POST --data "variable=my text is long" http://address
How can I get the same result of the curl command with an xquery function?
More in general, is this a good way to write a function in restxq when the variable is not a single word but the content of a file? (I am not even sure if a file can be passed as such in restxq)
Thanks, Joseph