Reputation: 195
I am using BaseX version 9.5, I am trying to send HTTP request from local to remote server to read database, but not getting the response.
let $server := 'http://10.102.xxx.xxx:8984/rest/'
let $sendreq := (http:send-request(
<http:request method='POST' username='admin' password='admin' send-authorization='true'
href='{$server}' auth-method='Basic'>
<http:body media-type="application/xml">
{
collection('test')/*
}</http:body>
</http:request>
))[2]
return $sendreq
Can anyone suggest how can I send query to remote server so that I could read and query to remote server database from my local server?
Upvotes: 1
Views: 208
Reputation: 1895
To execute your query on a remote instance of basex
http:send-request(
<http:request method='POST'
href='{$remote-server-rest-endpoint}'
username='{$remote-instance-user}'
password='{$remote-instance-user-password}'
send-authorization='true'
auth-method='Basic'>
<http:body media-type="application/xml">
<query xmlns="http://basex.org/rest">
<text><![CDATA[
declare variable $a as xs:integer external;
declare variable $b as xs:integer external;
<mult>{ $a * $b }</mult>
]]></text>
<variable name="a" value="21"/>
<variable name="b" value="2"/>
</query>
</http:body>
</http:request>
)
Adapted from the example found in the docs: https://docs.basex.org/wiki/REST#POST_Method
Upvotes: 0