Hello Christian, thanks for your quick response. Yes! That does indeed work if I put the url as a new document (I originally put it as just the database in which case it replaced the existing document).
For the log the little python code that worked is (assuming the db test2 exists):
import requests url1 = 'http://localhost:8984/rest/test2/test21.xml' tdata = '<greeting>hello</greeting>' r = requests.put(url1, data=tdata, auth=("admin", "admin"))
many thanks for your help! adil
On Tue, Jun 14, 2016 at 06:50:47PM +0200, Christian GrĂ¼n wrote:
Hi Adil,
Did you already check out our documentation [1]? Did you try PUT?
Cheers, Christian
[1] http://docs.basex.org/wiki/REST Am 14.06.2016 6:28 nachm. schrieb "Adil Hasan" paradox2005@gmail.com:
Hello, Thank you for your work in creating this database management system!
I have a question.
I have an XML document that is created in an script. I would like to store the xml document in the xml database. The xml file is created in memory and I'm using python and the REST API to store the data.
I can't figure out how to add an xml document to an existing database.
I tried a POST request with the data being:
<command xmlns="http://basex.org/rest"> <text>open test2; add to test21.xml <![CDATA[<greeting>hello3</greeting>]]></text> </command>
That fails telling me I cannot do multiple commands at one time. So, I thought I could add 2 command statements with the POST request:
<command xmlns="http://basex.org/rest"> <text>open test2</text> </command> <command xmlns="http://basex.org/rest"> <text>add to test21.xml <![CDATA[<greeting>hello3</greeting>]]></text> </command>
But, that also doesn't work. Does anyone have a suggestion as to how to add an xml document to an existing database (ideally the xml document is not in a file)?
many thanks for your help, adil