Scripting WebDAV

Last Updated: Apr 24, 2024
documentation for the dotCMS Content Management System

Note: dotCMS WebDAV support is now deprecated in favor of the dotCMS CLI.

Web-based Distributed Authoring and Versioning, or WebDAV, is an extension of the HTTP protocol that allows you to create a connection between your local computer and a server to easily transfer files between machines. For WebDav the command line tool Curl is used to manipulate files on the server.

To learn how to install WebDav take a look at Upload via WebDav.

When working with WebDAV, we recommend using Cyberduck — particularly in a Windows environment, as Windows support for WebDAV was announced as deprecated in November 2023.

Basic WebDAV Commands

There are four basic commands in Curl for WebDAV, Reading, Deleting, Renaming and Uploading.

Reading Files and Folders

WebDAV uses the Curl get command to reading files or folders. The get in Curl is implied so our command would look like:

curl ''

In dotCMS the url pattern is {server}/webdav/{live or working}/{languageid}/{site path}

If you are looking to get a response see Get Response Code.

Deleting Files and Folders

The -X DELETE command is used to delete an existing file or folder at the path specified.

To delete a folder:

curl -X DELETE ''

To delete a file:

curl -X DELETE ''

Renaming Files

To rename a file we use the Curl -X MOVE command because we are essentially creating a new file with the new name moving the contents of the old file to the new one and then deleting the file.

curl -X MOVE --header

Creating New Folder

Use -X MKCOL to make a new directory:

curl -X MKCOL ''

Uploading Files

The put command is used for uploading a file to WebDAV

curl -T '/path/to/local/file.txt' ''

In this example file.txt which is located at /path/to/local is being uploaded to our folder on WebDAV test

Curl –Options

Curl provides many useful options to enhance the basic calls.

Setting a Username and Password

To set a username and password for WebDav in curl use the following command:

curl --user 'userName:pass' ''

In this example userName is our chosen username and pass is the password to be set.

HTTP Authentication

To utilize your username and password set above you use authentication. There are three main option commands for authentication in Curl --basic, --digest, and --anyauth.

--anyauth chooses which authentication type is best for your situation between --basic and --digest. Even though you can choose manually which authentication you would like to use --anyauthis the recommended way to do authentication, especially for those new to Curl and WebDAV.

Below show all three authentication commands

curl --user 'user:pass' '' --basic
curl --user 'user:pass' '' --digest
curl --user 'user:pass' '' --anyauth

Get Response Code

Often in WebDAV you will want a response to know if the request was preformed. One option to know if the request was completed is to use the -sw option:

curl --user 'user:pass' -X DELETE '' -sw '%{http_code}'

On this page


We Dig Feedback

Selected excerpt: