hi Christian,
very many thanks
 
best regards
 
Gesendet: Dienstag, 12. April 2016 um 08:38 Uhr
Von: "Christian Grün" <christian.gruen@gmail.com>
An: "Oleg Duvanayev" <duvanaev@gmx.net>
Cc: BaseX <basex-talk@mailman.uni-konstanz.de>
Betreff: Re: [basex-talk] insert an xml structure in database
Hi Oleg,

Two things need to be considered to make your code work:

* Please have a closer look at the syntax of the ADD command. The "TO"
keyword is required to indicate that you are also specifying a
database path. This is how it should be: add to /kgw <book id="1" />

* If you enclose a command string with XML snippets, it needs to be
encoded (otherwise, XML will really be interpreted as XML, even before
the command will be interpreteed in a second step):

OLD:
<text><![CDATA[ add to /kgw <book id=\"1\" /> ]]></text>

Correct (1st variant):
<text> add to /kgw &lt;book id=\"1\" /&gt; </text>

Correct (2nd variant):
<text><![CDATA[ add to /kgw <book id=\"1\" /> ]]></text>

If you want to add XML via REST, it is probably easier, and faster, to
use the PUT method [1,2]. It allows you to both create new databases
and add/update its resources (and there will be no need to encode your
XML stream).

Hope this helps,
Christian

[1] http://docs.basex.org/wiki/REST#PUT_Method
[2] https://github.com/BaseXdb/basex/blob/master/basex-examples/src/main/java/org/basex/examples/rest/RESTPut.java



On Mon, Apr 11, 2016 at 7:37 PM, Oleg Duvanayev <duvanaev@gmx.net> wrote:
>
> dear lady and gentlemen,
>
> i have to add in a test database the simple document. I use the database, which is running as web-application in tomcat and access to database i do with REST. I tried to use this approatch, but it doesn't work for me. I take always the message "Bad request":
>
>
> In the attachment you find the method i use to take a resonse from database.
>
> I am really sorry, i can find solution. Could you please assist me to solve this issue ?
>
> The second missunderstanding is the description of commands.
>
>
> how can i use in my case for example "XML Syntax" ?
>
> very many thanks for any help
> best regards
> Oleg Duvanayev
>
>