Page 1 of 2
Communicate with a webdav server [SOLVED]
Posted: Sun Mar 24, 2019 8:48 am
by bangkok
I would like to communicate with a "webdav" server (Nextcloud, it's like a Dropbox system) for :
-upload file
-download file
-and PROPFIND (to get a listing of the server's files)
Everything works well... when I use CURL on Windows :
For instance :
Code: Select all
curl -u user:password -X PROPFIND "https://myserver.com/remote.php/webdav/"
But I would like to do it in a good "old fashioned" way with LC :
-by setting the proper http headers (set the httpheaders or libURLSetCustomHTTPHeaders)
-and then using POST (?), GET commands
Difficult to find any references.
If someone has a few working examples... it would help !

Re: Communicate with a webdav server
Posted: Sun Mar 24, 2019 11:10 am
by mrcoollion
Re: Communicate with a webdav server
Posted: Mon Mar 25, 2019 6:18 am
by bangkok
mrcoollion wrote: ↑Sun Mar 24, 2019 11:10 am
You can probably use tsNet for this.
That is my goal indeed... But only after I figure out the contents of the http headers, the XML data to be sent (with PROPFIND command for instance), etc.
Eventually, the idea is to create a library so LC can communicate with a webdav system.
Re: Communicate with a webdav server
Posted: Mon Mar 25, 2019 10:14 am
by FourthWorld
I haven't used WebDAV from LC yet, but I'll need to in the coming months. What header fields do you need to set? Perhaps I can put that into an example for both of us.
Re: Communicate with a webdav server
Posted: Mon Mar 25, 2019 11:17 am
by bangkok
FourthWorld wrote: ↑Mon Mar 25, 2019 10:14 am
I haven't used WebDAV from LC yet, but I'll need to in the coming months. What header fields do you need to set? Perhaps I can put that into an example for both of us.
First a simple PROPFIND would do (depth 0), in order to list all the files at root directory, with all their properties (the idea is to start with the simplest query).
Then, a query to upload a file, and to download.
Re: Communicate with a webdav server
Posted: Wed Mar 27, 2019 8:48 am
by bangkok
After hours of tests... I start to think that LC classic internet functions do not support the PROPFIND method !
Even by playing with httpheaders and libURLSetCustomHTTPHeaders.
I managed to get something working only by using tsNet : tsNetCustomSync (but it's available only in Indy edition).
Code: Select all
put true into pSettings["use_ssl"]
put true into pSettings["force_basic_auth"]
put "user" into pSettings["username"]
put "password" into pSettings["password"]
put tsNetCustomSync("https://myserver.com/remote.php/webdav/" , "PROPFIND", pHeaders, tResponseHeaders, tResult, tBytes,pSettings) into tData
answer tResponseHeaders
answer tData
Re: Communicate with a webdav server
Posted: Wed Mar 27, 2019 12:44 pm
by FourthWorld
What does your LibURL code look like?
Re: Communicate with a webdav server
Posted: Wed Mar 27, 2019 1:07 pm
by bangkok
FourthWorld wrote: ↑Wed Mar 27, 2019 12:44 pm
What does your LibURL code look like?
This is the header. I've tried with httpheaders and libURLSetCustomHTTPHeaders.
Code: Select all
PROPFIND HTTP/1.1
Host: myserver.com
Authorization: Basic xxxxxxxxxxxxxxxxxxx
Content-Type: text/xml
Content-Length: 86
Depth: 1
Accept: */*
<?xml version="1.0" ?>
<D:propfind xmlns:D="DAV:">
<D:allprop/>
</D:propfind>
then after I do a :
Code: Select all
get url ("https://myserver.com/remote.php/webdav/")
Whatever I do, the field in which libURLSetLogField puts the logs, always contains :
GET /remote.php/webdav/ HTTP/1.1
Nowhere I see PROPFIND HTTP/1.1
And always error 400 (bad request).
Re: Communicate with a webdav server
Posted: Tue Dec 24, 2019 10:21 am
by FourthWorld
Did you find a workaround for that header issue?
If need be we can fork libURL for WbDAV support. I have some things on the horizon that need WebDAV.
Re: Communicate with a webdav server
Posted: Wed Dec 25, 2019 11:14 am
by bangkok
FourthWorld wrote: ↑Tue Dec 24, 2019 10:21 am
Did you find a workaround for that header issue?
If need be we can fork libURL for WbDAV support. I have some things on the horizon that need WebDAV.
Unfortunately no.
So if you have a solution, I would be glad to try it.
Re: Communicate with a webdav server
Posted: Sat Feb 08, 2020 3:22 pm
by bangkok
We are... not alone.
Someone else is toying with Webdav !
http://lists.runrev.com/pipermail/use-l ... 58397.html
Re: Communicate with a webdav server
Posted: Mon Feb 17, 2020 8:24 am
by bangkok
Matthias Rebbe was kind enough to help me and he made a sample stack.
Here is his original stack and my version (with a few changes for full compatibility with NextCloud, along with a system to convert the XML received in Json Array, thanks to Trevor Devor's function ).
You can :
-upload a file
-download a file
-create a folder
-delete a folder/file
-list the content of a folder (method PROPFIND)
For the "upload" function, 1 of my 2 instances (the one with a problem with SSL certificate) refused to work properly ... Always timeout message.
But the parameter :
Code: Select all
put true into pSettings["force_basic_auth"]
... solved the issue (but I still do not know why).
Anyway. With those 2 stacks, it's a good begining to work with Web Dav systems and Livecode. Have fun.
And if you want to add your own "grain of salt" (new functions etc.) do not hesitate !
Re: Communicate with a webdav server [SOLVED]
Posted: Fri Feb 21, 2020 9:17 pm
by FourthWorld
Very handy. Thanks for posting that.
Re: Communicate with a webdav server [SOLVED]
Posted: Sat Feb 22, 2020 5:49 am
by mwieder
Oh, my! Yes, thanks to both you and Matthias - that's awesome.
Re: Communicate with a webdav server [SOLVED]
Posted: Sat Apr 11, 2020 5:50 pm
by rabit
I'm coming late to the party, but there is a WebDAV library which
does not depend on tsNet and can therefore also be used
with the Community Edition.
See here:
https://github.com/revig/livecode-webdavlib