using rest api to move a file

Thursday, 22 September 2016 · 5 messages
AH
Adil Hasan22 Sep 2016 10:44 #
Hello, I hope you can help me I'm going a bit mad with this (I had it working before, but don't have the notes of what I did). I have in a database an xml file: http://localhost:8484/rest/test/test1.xml I would like to move the xml file to a different database: http://localhost:8984/rest/test-moved I tried the following:
curl -utest:test -X POST -H "Content-Type: application/xml;charset=UTF-8" -d '@/home/hasan/move.xml' -i "http://localhost:8984/rest/test"
where my move.xml has:
<command xmlns="http://basex.org/rest">
<text> rename test1.xml test-moved/test1.xml </text>
</command>
The command returns a 200, but nothing has moved. I am clearly doing something wrong. If I change the URL in the cURL request to "http://localhost:8984/rest" I get a java null pointer exception. Do you know they syntax I should use for the REST API to move a file? many thanks, adil
CG
Christian Grün22 Sep 2016 17:19 #
Hi Adil, Thanks for mentioning the null pointer exception, this is clearly something that should be fixed (if you are interested, you can follow the issue that I’ve just created [1]). rename test1.xml test-moved/test1.xml With this command, you can move documents inside a single database. There is currently no fixed solution to move resources across database, so you’ll probably have to use two requests for this (GET and PUT). Hope this helps Christian [1] https://github.com/BaseXdb/basex/issues/1358
Quoted text · Adil Hasan · 10 lines
> </command> > > The command returns a 200, but nothing has moved. I am clearly doing something > wrong. If I change the URL in the cURL request to "http://localhost:8984/rest" > I get a java null pointer exception. > > Do you know they syntax I should use for the REST API to move a file? > > many thanks, > adil
LV
Lizzi, Vincent22 Sep 2016 18:32 #
Adil, If you can use RESTXQ to create a function, you could use something like:
db:add($todb, db:open($fromdb, $path), $path)
inside a function available that is made available via RESTXQ. Vincent http://docs.basex.org/wiki/RESTXQ
Quoted text · basex-talk-bounces at mailman.uni-konstanz.de · 27 lines
From: basex-talk-bounces at mailman.uni-konstanz.de [mailto:basex-talk-bounces at mailman.uni-konstanz.de] On Behalf Of Christian Grün Sent: Thursday, September 22, 2016 11:19 AM To: Adil Hasan <paradox2005 at gmail.com> Cc: BaseX <basex-talk at mailman.uni-konstanz.de> Subject: Re: [basex-talk] using rest api to move a file Hi Adil, Thanks for mentioning the null pointer exception, this is clearly something that should be fixed (if you are interested, you can follow the issue that I’ve just created [1]). rename test1.xml test-moved/test1.xml With this command, you can move documents inside a single database. There is currently no fixed solution to move resources across database, so you’ll probably have to use two requests for this (GET and PUT). Hope this helps Christian [1] https://github.com/BaseXdb/basex/issues/1358<https://github.com/BaseXdb/basex/issues/1358> > </command> > > The command returns a 200, but nothing has moved. I am clearly doing something > wrong. If I change the URL in the cURL request to "http://localhost:8984/rest" > I get a java null pointer exception. > > Do you know they syntax I should use for the REST API to move a file? > > many thanks, > adil
AH
Adil Hasan22 Sep 2016 23:28 #
Hello Vincent, thanks for the suggestion. I'm not familiar with RESTXQ I can give it a try. thanks, adil
Quoted text · Vincent · 50 lines
On Thu, Sep 22, 2016 at 04:32:39PM +0000, Lizzi, Vincent wrote: > Adil, > > If you can use RESTXQ to create a function, you could use something like: > > db:add($todb, db:open($fromdb, $path), $path) > > inside a function available that is made available via RESTXQ. > > Vincent > > http://docs.basex.org/wiki/RESTXQ > > > From: basex-talk-bounces at mailman.uni-konstanz.de [mailto:basex-talk-bounces at mailman.uni-konstanz.de] On Behalf Of Christian Grün > Sent: Thursday, September 22, 2016 11:19 AM > To: Adil Hasan <paradox2005 at gmail.com> > Cc: BaseX <basex-talk at mailman.uni-konstanz.de> > Subject: Re: [basex-talk] using rest api to move a file > > Hi Adil, > > Thanks for mentioning the null pointer exception, this is clearly > something that should be fixed (if you are interested, you can follow > the issue that I’ve just created [1]). > > rename test1.xml test-moved/test1.xml > > With this command, you can move documents inside a single database. > There is currently no fixed solution to move resources across > database, so you’ll probably have to use two requests for this (GET > and PUT). > > Hope this helps > Christian > > [1] https://github.com/BaseXdb/basex/issues/1358<https://github.com/BaseXdb/basex/issues/1358> > > > > > </command> > > > > The command returns a 200, but nothing has moved. I am clearly doing something > > wrong. If I change the URL in the cURL request to "http://localhost:8984/rest" > > I get a java null pointer exception. > > > > Do you know they syntax I should use for the REST API to move a file? > > > > many thanks, > > adil
AH
Adil Hasanin reply to Christian Grün, 22 Sep 2016, 17:1922 Sep 2016 23:31 #
Hello Christian, thanks for the suggestions. I can try that. Thanks also for the github issue I'll check it out. many thanks, adil
Quoted text · Christian Grün · 31 lines
On Thu, Sep 22, 2016 at 05:19:16PM +0200, Christian Grün wrote: > Hi Adil, > > Thanks for mentioning the null pointer exception, this is clearly > something that should be fixed (if you are interested, you can follow > the issue that I’ve just created [1]). > > rename test1.xml test-moved/test1.xml > > With this command, you can move documents inside a single database. > There is currently no fixed solution to move resources across > database, so you’ll probably have to use two requests for this (GET > and PUT). > > Hope this helps > Christian > > [1] https://github.com/BaseXdb/basex/issues/1358 > > > > > </command> > > > > The command returns a 200, but nothing has moved. I am clearly doing something > > wrong. If I change the URL in the cURL request to "http://localhost:8984/rest" > > I get a java null pointer exception. > > > > Do you know they syntax I should use for the REST API to move a file? > > > > many thanks, > > adil

⚡Generated with XQuery