# How to specify a webdav backend root path using connection string syntax

**URL:** <https://forum.rclone.org/t/how-to-specify-a-webdav-backend-root-path-using-connection-string-syntax/31092>\
**Category:** Help and Support\
**Created:** [June 2, 2022, 3:00pm UTC](https://forum.rclone.org/t/how-to-specify-a-webdav-backend-root-path-using-connection-string-syntax/31092 "2022-06-02T15:00:58Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![rcuser\_rb](https://forum.rclone.org/user_avatar/forum.rclone.org/rcuser_rb/32/9240_2.png) [@rcuser\_rb](https://forum.rclone.org/u/rcuser_rb)\
**Post date:** [June 2, 2022, 3:00pm UTC](https://forum.rclone.org/t/how-to-specify-a-webdav-backend-root-path-using-connection-string-syntax/31092/1 "2022-06-02T15:00:58Z")

</div>

#### What is the problem you are having with rclone?

When doing an rc copy (see command below) it fails on the PROPFIND of the src webdav backend. The issue is that the src webdav service (running at a host with a path: `https://app.cs3mesh-iop.k8s.surfsara.nl/iop`, which in this case is a particular server setup) returns the resource items with a href starting from that path: eg. `/remote.php/webdav/home/folder1/test1.txt`

Now the rclone webdav backend implementation compares the returned items' paths with the path of the base url which reads `/iop/remote.php/webdav/home/folder1/test1.txt` (ie. including the `/iop` part). And thus it fails to recognize the path (see debug output below).

Shifting the `/iop` part to the path (`url=\"https://app.cs3mesh-iop.k8s.surfsara.nl\":/iop/remote.php/webdav/home/folder1"`) gives the same result.

So, I tried to use the `_root` special value to specify a backend root as follows:  
`rclone -vv copy ":webdav,headers=\"x-access-token,...token...\",url=\"https://app.cs3mesh-iop.k8s.surfsara.nl\",_root=/iop:/remote.php/webdav/home/folder1" /tmp/folder2`  
but that does not seem to do anything. The root part is missing in the PROPFIND request.

Two questions:

- How do I use `_root` in the connection string syntax, or is `_root` actually meant for this?
- What's the rational behind the comparison at [rclone/backend/webdav/webdav.go at a9c49c50a06ebf7cea0aaa3329dd0fb3b9fcef9a · rclone/rclone · GitHub](https://github.com/rclone/rclone/blob/a9c49c50a06ebf7cea0aaa3329dd0fb3b9fcef9a/backend/webdav/webdav.go#L710) ? (to me it seems that when I'm asking for a path (`:/remote.php/webdav/...`) and PROPFIND returns items that have that have exactly then that would be correct).

#### Run the command 'rclone version' and share the full output of the command.

rclone v1.58.1

- os/version: centos 8.5.2111 (64 bit)
- os/kernel: 5.10.102.1-microsoft-standard-WSL2 (x86\_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.17.9
- go/linking: static
- go/tags: none

#### Which cloud storage system are you using? (eg Google Drive)

owncloud

#### The command you were trying to run (eg `rclone copy /tmp remote:tmp`)

```auto
rclone -vv copy ":webdav,headers=\"x-access-token,...token...\",url=\"https://app.cs3mesh-iop.k8s.surfsara.nl/iop\":/remote.php/webdav/home/folder1" /tmp/folder2

```

#### The rclone config contents with secrets removed.

```auto
using connection strings syntax; see command above

```

#### A log from the command with the `-vv` flag

```auto
2022/06/02 14:03:11 DEBUG : rclone: Version "v1.58.1" starting with parameters ["rclone" "-vv" "copy" ":webdav,headers=\"x-access-token,...token...\",url=\"https://app.cs3mesh-iop.k8s.surfsara.nl/iop\":/remote.php/webdav/home/folder1" "/tmp/folder2"]
2022/06/02 14:03:11 DEBUG : Creating backend with remote ":webdav,headers=\"x-access-token,...token...\",url=\"https://app.cs3mesh-iop.k8s.surfsara.nl/iop\":/remote.php/webdav/home/folder1"
2022/06/02 14:03:11 DEBUG : :webdav: detected overridden config - adding "{kKeur}" suffix to name
2022/06/02 14:03:11 DEBUG : Using config file from "/config/rclone/rclone.conf"
2022/06/02 14:03:11 DEBUG : found headers: x-access-token,...token...
2022/06/02 14:03:11 DEBUG : fs cache: renaming cache item ":webdav,headers=\"x-access-token,...token...\",url=\"https://app.cs3mesh-iop.k8s.surfsara.nl/iop\":/remote.php/webdav/home/folder1" to be canonical ":webdav{kKeur}:remote.php/webdav/home/folder1"
2022/06/02 14:03:11 DEBUG : Creating backend with remote "/tmp/folder2"
2022/06/02 14:03:11 DEBUG : Item with unknown path received: "/remote.php/webdav/home/folder1/", "/iop/remote.php/webdav/home/folder1/"
2022/06/02 14:03:11 DEBUG : Item with unknown path received: "/remote.php/webdav/home/folder1/test1.txt", "/iop/remote.php/webdav/home/folder1/"
2022/06/02 14:03:11 DEBUG : Local file system at /tmp/folder2: Waiting for checks to finish
2022/06/02 14:03:11 DEBUG : Local file system at /tmp/folder2: Waiting for transfers to finish
2022/06/02 14:03:11 INFO : There was nothing to transfer
2022/06/02 14:03:11 INFO :
Transferred: 0 B / 0 B, -, 0 B/s, ETA -
Elapsed time: 0.1s

2022/06/02 14:03:11 DEBUG : 4 go routines active

```

---

<div class="post-metadata">

**Author:** ![jwink3101](https://forum.rclone.org/letter_avatar_proxy/v4/letter/j/b38774/32.png) [@jwink3101](https://forum.rclone.org/u/jwink3101)\
**Post date:** [June 2, 2022, 8:05pm UTC](https://forum.rclone.org/t/how-to-specify-a-webdav-backend-root-path-using-connection-string-syntax/31092/2 "2022-06-02T20:05:14Z")

</div>

A few things:

1. I've never heard of `_root` and it isn't in [the docs](https://rclone.org/webdav/) either. Where is that from?
2. I know you eventually want to use connection strings, but what happens when you move the configurable options out of them and into a config file? You still will need things like the headers in the string (I think).
  - Are you 100% sure your escaping and joining is correct? I've struggled with that a lot and finally just made a quick python tool to CSV encode and then shell escape it to be certain.

---

<div class="post-metadata">

**Author:** ![rcuser\_rb](https://forum.rclone.org/user_avatar/forum.rclone.org/rcuser_rb/32/9240_2.png) [@rcuser\_rb](https://forum.rclone.org/u/rcuser_rb)\
**Post date:** [June 3, 2022, 6:50am UTC](https://forum.rclone.org/t/how-to-specify-a-webdav-backend-root-path-using-connection-string-syntax/31092/3 "2022-06-03T06:50:32Z")

</div>

1. It's documented here [Remote Control / API](https://rclone.org/rc/#specifying-remotes-to-work-on)
2. For our use case connection strings is the only way.

As far as escaping&joining is concerned, I can only say that I've tried about every conf that I can think of ;). So far I've found that the `_root` value doesn't seem to be picked up (the way I've hoped).

---

<div class="post-metadata">

**Author:** ![ncw](https://forum.rclone.org/user_avatar/forum.rclone.org/ncw/32/18_2.png) [@ncw](https://forum.rclone.org/u/ncw)\
**Post date:** [June 3, 2022, 1:44pm UTC](https://forum.rclone.org/t/how-to-specify-a-webdav-backend-root-path-using-connection-string-syntax/31092/4 "2022-06-03T13:44:15Z")

</div>

> [@rcuser\_rb](#):
>
> So, I tried to use the `_root` special value to specify a backend root as follows:

The `_root` parameter is only for use over the API and will be ignored otherwise.

What you want to do is move the path to the `url` parameter passed to webdav eg `https://app.cs3mesh-iop.k8s.surfsara.nl/iop/remote.php/`. That might not work - you might need to move more to the `url` parameter, but hopefully you get the idea.

---

<div class="post-metadata">

**Author:** ![rcuser\_rb](https://forum.rclone.org/user_avatar/forum.rclone.org/rcuser_rb/32/9240_2.png) [@rcuser\_rb](https://forum.rclone.org/u/rcuser_rb)\
**Post date:** [June 3, 2022, 3:09pm UTC](https://forum.rclone.org/t/how-to-specify-a-webdav-backend-root-path-using-connection-string-syntax/31092/5 "2022-06-03T15:09:33Z")

</div>

Hi @ncw ,  
Unfortunately that doesn't work either. The `baseURL.Path` in the [check](https://github.com/rclone/rclone/blob/a9c49c50a06ebf7cea0aaa3329dd0fb3b9fcef9a/backend/webdav/webdav.go#L710) always starts with `/iop` of the full url path. But our webdav service never returns item paths starting with `/iop`. It considers that part of the webdav endpoint so to speak.  
And so the check fails. Here's eg. the relevant debug output of that check after using your suggestion:  
`Item with unknown path received: "/remote.php/webdav/home/folder1/", "/iop/remote.php/webdav/home/folder1/"`  
Moving more fragments over to the `url` parameter gives a similar result.

I'm still wondering about the nature of this check, why it checks the items' paths against the full request url path even though the first part of it is not included in the request path to begin with? But I also don't know if there's a standard for this.

---

<div class="post-metadata">

**Author:** ![ncw](https://forum.rclone.org/user_avatar/forum.rclone.org/ncw/32/18_2.png) [@ncw](https://forum.rclone.org/u/ncw)\
**Post date:** [June 4, 2022, 5:10pm UTC](https://forum.rclone.org/t/how-to-specify-a-webdav-backend-root-path-using-connection-string-syntax/31092/6 "2022-06-04T17:10:07Z")

</div>

> [@rcuser\_rb](#):
>
> I'm still wondering about the nature of this check, why it checks the items' paths against the full request url path even though the first part of it is not included in the request path to begin with?

Its because rclone needs to work out the paths of things relative to the root of the webdav server. It therefore wants to take `/remote.php/webdav/home/folder1/` and turn it into `home/folder1` or something like that.

All the webdav servers I've seen so far work like that, but webdav isn't a very well standardized protocol and there is a lot of variety in servers.

What you are asking for is a URL which is different to the service URL for rclone to remove from all front of all the paths.

It wouldn't be impossible to add such a URL as an additional parameter.

Maybe rclone could even work it out itself...

---

<div class="post-metadata">

**Author:** ![rcuser\_rb](https://forum.rclone.org/user_avatar/forum.rclone.org/rcuser_rb/32/9240_2.png) [@rcuser\_rb](https://forum.rclone.org/u/rcuser_rb)\
**Post date:** [June 8, 2022, 11:27am UTC](https://forum.rclone.org/t/how-to-specify-a-webdav-backend-root-path-using-connection-string-syntax/31092/7 "2022-06-08T11:27:09Z")

</div>

Thanks for the explanation. So after re-checking (the code) I realized that for our use case a simple modification is enough. By not always trimming the `root` for a leading slash [here](https://github.com/rclone/rclone/blob/e11bfacfcf42e528942246c7248d2412f9d3977a/backend/webdav/webdav.go#L381) (also removing the same redundant! line [here](https://github.com/rclone/rclone/blob/e11bfacfcf42e528942246c7248d2412f9d3977a/backend/webdav/webdav.go#L396)) one can play with the path having a leading slash or not.  
Now the [check](https://github.com/rclone/rclone/blob/e11bfacfcf42e528942246c7248d2412f9d3977a/backend/webdav/webdav.go#L710) now makes sense and works.

Eg. Path with a leading slash:  
`:webdav,url="http://somewhere.org/api":/remote.php/webdav/folder1` will now test the returned items for starting with `/remote.php/webdav/folder1`

and path without a leading slash:  
`:webdav,url="http://somewhere.org/api":remote.php/webdav/folder1` will now test the returned items for starting with `/api/remote.php/webdav/folder1`

After doing this code modification I ran the code tests locally(!) and they appear to be fully in order (and real-world copying tests now also work as expected).

I'm curious to hear what you think, and possibly overlooked.

---

<div class="post-metadata">

**Author:** ![ncw](https://forum.rclone.org/user_avatar/forum.rclone.org/ncw/32/18_2.png) [@ncw](https://forum.rclone.org/u/ncw)\
**Post date:** [June 8, 2022, 1:39pm UTC](https://forum.rclone.org/t/how-to-specify-a-webdav-backend-root-path-using-connection-string-syntax/31092/8 "2022-06-08T13:39:53Z")

</div>

That is an interesting workaround.

Rclone users are fond of writing `remote:/path/to/file` even though everywhere the docs state use `remote:path/to/file` and I think your patch would break that.

I think we probably do need to keep trimming the slashes off the right hand side too as users quite often write `remote:path/to/dir/`

Here is the alternative approach with a `base_path` parameter which you'll need to set to `/remote.php/webdav/home/folder1/` assuming you are using the `url` `https://app.cs3mesh-iop.k8s.surfsara.nl/iop/webdav/home/folder1/`

[v1.59.0-beta.6181.dfc5b0460.fix-webdav-base-path](https://beta.rclone.org/branch/fix-webdav-base-path/v1.59.0-beta.6181.dfc5b0460.fix-webdav-base-path/) on branch [fix-webdav-base-path](https://github.com/rclone/rclone/tree/fix-webdav-base-path) (uploaded in 15-30 mins)

That said, I'm not convinced that this is the right thing to do for your webdav server. It seems perfectly happy to respond without the `/iop/` part, so have you tried `url` `https://app.cs3mesh-iop.k8s.surfsara.nl/remote.php/webdav/` in the original rclone?

That might need to be `https://app.cs3mesh-iop.k8s.surfsara.nl/remote.php/webdav/home/folder1` or similar, it depends on exactly what you are trying to achieve.

Any webdav server with `remote.php/webdav` in the URL is most likely based on the same PHP serving library as used by nextcloud and owncloud and their URLs look like `https://example.com/remote.php/webdav/` so I would expect that form to work here too.

---

<div class="post-metadata">

**Author:** ![rcuser\_rb](https://forum.rclone.org/user_avatar/forum.rclone.org/rcuser_rb/32/9240_2.png) [@rcuser\_rb](https://forum.rclone.org/u/rcuser_rb)\
**Post date:** [June 13, 2022, 7:43am UTC](https://forum.rclone.org/t/how-to-specify-a-webdav-backend-root-path-using-connection-string-syntax/31092/9 "2022-06-13T07:43:57Z")

</div>

> [@ncw](#):
>
> That said, I'm not convinced that this is the right thing to do for your webdav server. It seems perfectly happy to respond without the `/iop/` part, so have you tried `url` `https://app.cs3mesh-iop.k8s.surfsara.nl/remote.php/webdav/` in the original rclone?

The issue there is that if the `/iop` part is missing the request doesn't get directed to the webdav service. However the underlying platform webservice is oblivious to this, and so it doesn't return that part. But the [project](https://github.com/cs3org/reva) (you are aware of it 🙂 ) is also under development and configurations change constantly. I do understand the confusion it can cause in webdav clients. Initially I thought the `_root` special value would help in a situation like this ...

So I think we should leave this for now, and try to solve it from our end.

--  
ps. Here's what I experienced trying out you `base_path` parameter fix on our webservices:

> [@ncw](#):
>
> Here is the alternative approach with a `base_path` parameter which you'll need to set to `/remote.php/webdav/home/folder1/` assuming you are using the `url` `https://app.cs3mesh-iop.k8s.surfsara.nl/iop/webdav/home/folder1/`
> 
> [v1.59.0-beta.6181.dfc5b0460.fix-webdav-base-path](https://beta.rclone.org/branch/fix-webdav-base-path/v1.59.0-beta.6181.dfc5b0460.fix-webdav-base-path/) on branch [fix-webdav-base-path](https://github.com/rclone/rclone/tree/fix-webdav-base-path) (uploaded in 15-30 mins)

That works for `rclone lsd`. But I do get some errors on folders when using `ls` and `lsl`.  
This is the output for `.../folder1` which contains the 2 files and a folder `tmp`:

```auto
     1143 test1.txt
       20 test2.txt
2022/06/09 09:09:23 ERROR : tmp/tmp: error listing: directory not found

```

I have yet to find out what happens here.

(Thanks for the support!)

---

<div class="post-metadata">

**Author:** ![Ole](https://forum.rclone.org/user_avatar/forum.rclone.org/ole/32/9242_2.png) [@Ole](https://forum.rclone.org/u/Ole)\
**Post date:** [June 13, 2022, 10:19am UTC](https://forum.rclone.org/t/how-to-specify-a-webdav-backend-root-path-using-connection-string-syntax/31092/10 "2022-06-13T10:19:47Z")

</div>

Hi Nick, just a little clarification...

> [@ncw](#):
>
> Rclone users are fond of writing `remote:/path/to/file` even though everywhere the docs state use `remote:path/to/file`

This is not quite right, the leading / is indeed needed in a few situations and recommended in [the docs](https://rclone.org/sftp/):

> Note that some SFTP servers will need the leading / - Synology is a good example of this. [rsync.net](http://rsync.net), on the other hand, requires users to OMIT the leading /.

> [@ncw](#):
>
> I think your patch would break that.

I agree.

---

<div class="post-metadata">

**Author:** ![ncw](https://forum.rclone.org/user_avatar/forum.rclone.org/ncw/32/18_2.png) [@ncw](https://forum.rclone.org/u/ncw)\
**Post date:** [June 13, 2022, 10:39am UTC](https://forum.rclone.org/t/how-to-specify-a-webdav-backend-root-path-using-connection-string-syntax/31092/11 "2022-06-13T10:39:55Z")

</div>

> [@rcuser\_rb](#):
>
> So I think we should leave this for now, and try to solve it from our end.

Ok!

Let me know if you want more help 🙂

> [@rcuser\_rb](#):
>
> ps. Here's what I experienced trying out you `base_path` parameter fix on our webservices:

Hmm, not sure entirely what is going on there - would probable need access to the server to debug!

---

<div class="post-metadata">

**Author:** ![system](https://forum.rclone.org/uploads/default/original/2X/3/39ad3235f6ffec76ccd0c81616bd55697b4c300d.png) [@system](https://forum.rclone.org/u/system)\
**Post date:** [July 13, 2022, 10:40am UTC](https://forum.rclone.org/t/how-to-specify-a-webdav-backend-root-path-using-connection-string-syntax/31092/12 "2022-07-13T10:40:24Z")

</div>

Closed on July 13, 2022, 10:40am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
