Hi Christian
Sorry, chopped that out of the real thing in a bit of a hurry and made a bit of a mess of it. Here's something slightly closer to a SSCE.
Module under WEBPATH
xquery version "3.1" encoding "utf-8"; module namespace example = 'http://localhost/example'; 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 $targetrestxqproc := 'http://localhost:8984/example/post/' 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 <example xmlns:http="http://expath.org/ns/http-client"/>
Using curl from a DOS prompt
c:\apps\curl\curl -F"file=@example.xml;type=application/xml" http://localhost:8984/example/post/examplecurl.xml
Result in exampledb is <example/>
The addition of the namespace in the first case came as a bit of a surprise to me.
Thanks, chris