Module under WEBPATH
xquery version "3.1" encoding "utf-8";
declare
%rest:path("/example/post/{$fname}")
%rest:POST("{$body}")
%updating
function example:post($fname, $body as document-node())
{db:replace('exampledb', '/post/'||$fname, $body) };
Script run in BaseX GUI
let $file := 'C:\temp\xq\example.xml'
let $fname := 'example.xml'
let $body := fetch:xml($file, map { 'chop': true() })
return http:send-request(<http:request href="{$targetrestxqproc||$fname}"
method='POST'>
<http:body media-type='text/xml'>{$body}</http:body>
</http:request>)
Result in exampledb is
Using curl from a DOS prompt
Result in exampledb is
<example/>
The addition of the namespace in the first case came as a bit of a surprise to me.