PUT command with Rest client
Sunday, 30 August 2026 · 3 messages · last reply 6 Sep 2026
CF
Csaba Fekete30 Aug 2026 15:28 #
Hi all
I'm sure I'm missing something trivial but I can't seem to use the Rest client to PUT a document to a database.
*Here's the request:*
POST http://172.25.0.4:8080/rest/my_db
Accept: application/xml
Content-Type: application/xml
Authorization: Basic .....
<commands>
<put path='TEST.xml'><![CDATA[<hello>world</hello>]]></put>
</commands>*The response is:*
HTTP/1.1 500 Server Error
Server: Jetty(12.1.11)
Date: Sun, 30 Aug 2026 12:47:55 GMT
Content-Type: text/plain;charset=utf-8
Content-Length: 55
Resource "/<hello>world</hello>" not found.
Looks like it is treating the input as a file name, rather than XML string?
Any ideas are appreciated.
Best,
Csaba
CG
Christian Grün30 Aug 2026 22:59 #
Hi Csaba,
Your request will be successful if you send your input as XML, not CDATA:
<commands>
<put path='TEST.xml'><![CDATA[<hello>world</hello>]]></put>
</commands>An easier solution is to use the PUT method and specify the name of the resource in the URL:
POST http://172.25.0.4:8080/rest/my_db/TEST.xml
Body: <hello>world</hello>
Best,
Christian
Quoted text · Csaba Fekete · 25 lines
Von: Csaba Fekete via BaseX-Talk <basex-talk at mailman.uni-konstanz.de> Gesendet: Sonntag, 30. August 2026 15:28 An: BaseX Betreff: [basex-talk] PUT command with Rest client Hi all I'm sure I'm missing something trivial but I can't seem to use the Rest client to PUT a document to a database. Here's the request: POST http://172.25.0.4:8080/rest/my_db Accept: application/xml Content-Type: application/xml Authorization: Basic ..... <commands> <put path='TEST.xml'><![CDATA[<hello>world</hello>]]></put> </commands> The response is: HTTP/1.1 500 Server Error Server: Jetty(12.1.11) Date: Sun, 30 Aug 2026 12:47:55 GMT Content-Type: text/plain;charset=utf-8 Content-Length: 55 Resource "/<hello>world</hello>" not found. Looks like it is treating the input as a file name, rather than XML string? Any ideas are appreciated. Best, Csaba
CF
Csaba Fekete6 Sep 2026 10:22 #
Makes sense, thanks!
I realized there was a section for this in the docs as well.
Quoted text · Christian Grün · 57 lines
On Sun, 30 Aug 2026 at 22:59, Christian Grün <cg at basex.org> wrote: > Hi Csaba, > > Your request will be successful if you send your input as XML, not CDATA: > > <commands> > <put path='TEST.xml'><![CDATA[<hello>world</hello>]]></put> > </commands> > > An easier solution is to use the PUT method and specify the name of the > resource in the URL: > > POST http://172.25.0.4:8080/rest/my_db/TEST.xml > Body: <hello>world</hello> > > Best, > Christian > ________________________________________ > > Von: Csaba Fekete via BaseX-Talk <basex-talk at mailman.uni-konstanz.de> > Gesendet: Sonntag, 30. August 2026 15:28 > An: BaseX > Betreff: [basex-talk] PUT command with Rest client > > Hi all > > I'm sure I'm missing something trivial but I can't seem to use the Rest > client to PUT a document to a database. > > Here's the request: > > POST http://172.25.0.4:8080/rest/my_db > Accept: application/xml > Content-Type: application/xml > Authorization: Basic ..... > > <commands> > <put path='TEST.xml'><![CDATA[<hello>world</hello>]]></put> > </commands> > > The response is: > > HTTP/1.1 500 Server Error > Server: Jetty(12.1.11) > Date: Sun, 30 Aug 2026 12:47:55 GMT > Content-Type: text/plain;charset=utf-8 > Content-Length: 55 > > Resource "/<hello>world</hello>" not found. > > Looks like it is treating the input as a file name, rather than XML string? > > Any ideas are appreciated. > > Best, > Csaba >
Written for BaseX 12.4. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery