Support Center

Working With JavaScript WebDAV Client

Last Updated: May 16, 2013 06:28PM UTC

Use this tutorial to perform various operations on files and folders in AutoCAD 360 using the JavaScript WebDAV client.


After completing this tutorial, you would be able to:

  • Connect to an AutoCAD 360 account.
  • Query the file and folder directory for an account.
  • Perform various operations like copy, move, delete, and create folder.
  • Query file metadata.
  • Launch a drawing in AutoCAD 360 editor.

The Webdav client JavaScript class relies on the standard WebDAV protocol to communicate with AutoCAD 360 service.


Connecting to AutoCAD 360 Web Server


The constructor of the Webdav client class expects three arguments:

  • URL – specifies the WebDAV server address. For example, if you want to connect to AutoCAD 360 server, use:
  • Username – specifies your AutoCAD 360 account.
  • Password – specifies your AutoCAD 360 account password.

This sample code creates a new WebDAV client, connecting to the AutoCAD 360server, with the username 'someuser' and password '123456'.

WebDAVClient client = new WebdavClient("", "someuser", "123456");

Querying Files and Folders

Use the PROPFIND method to retrieve information about files and folders in AutoCAD 360 account.


PROPFIND / <handle>


The PROPFIND method receives three arguments:

  • handler – specifies an object that defines the callback functions onError and onSuccess, which are called when an error occurs during the request or when the request is successful.
  • path – specifies the relative path to the folder/file for which we wish to retrieve information.
  • depth – specifies whether the method is to be applied only to the resource (Depth = "0″), to the resource and its internal members only (Depth = "1″), or the resource and all its members (Depth = "infinity").


Use this sample code, which sends a request to AutoCAD 360 web server for retrieving information about all files and folders within the Site directory:


//A handler the implements onSuccess and onError functions
var handler = new PropfindHandler();
// request properties of all files/folders residing directly under the 'Site' folder.
client.PROPFIND(handler, '/Site', 1);

The following code example shows a sample XML that the WebDAV server returns containing all the information about the files and folders.


      HTTP/1.1 200 OK
      HTTP/1.1 200 OK

The files/folders are returned in d:response tag. In this example, the server returns information about two files, 'filea.dwg' and 'fileb.dwg'. For each file, the server states the creation date and its name.


The following code demonstrates an implementation of the PropFindHandler, which shows an alert message box containing the status code in case of an error, or the names of the files/folders returned by the server in case of success:


function PropfindHandler()
PropfindHandler.prototype.onSuccess = function(result)
    var names = '';
    // each file/folder is defined within a 'response' tag
    var items = this.getElementByTagName(result.content, 'd', 'response');
    for (i = 0; i < items.length; i++)
        var props = this.getElementByTagName(items[i], 'd', 'prop')[0]; 
        var displayNameTag = this.getElementByTagName(props, 'd', 'displayname')[0];
        var displayName = displayNameTag.childNodes[0].nodeValue;
        names += displayName + '/n';
PropfindHandler.prototype.onError = function(result)

In this example, the user will see these file names printed to the console:



Copying, Moving, and Deleting Files

Use the PROPFIND method to copy, move, and delete files.


Using this sample code, you can:

  • Copy /Site/filea.dwg to /OtherSite/fileb.dwg
  • Move /Site/filec.dwg to /OtherSite/filed.dwg
  • Delete /Site/filee.dwg

var handler = new FSHandler();
var overwrite = true;
client.COPY(handler, '/Site/filea.dwg', '/OtherSite/fileb.dwg', overwrite);
client.MOVE(handler, '/Site/filec.dwg', '/OtherSite/filed.dwg', overwrite);
client.DELETE(handler, '/Site/filee.dwg');

You should subscribe a callback function to the appropriate event (DeleteComplete, CopyComplete, MoveComplete, UploadComplete). In these cases, there is no response to parse, but using the callback you will be notified when the operation is finished and whether it is was successful.


The following example shows the FSHandler method that show a message box with the message 'success' in case the request ended successfully or the message 'error' with the status code in case of an error:


function FSHandler()
FSHandler.prototype.onSuccess = function(result)
FSHandler.prototype.onError = function(result)
    alert('error: ' + result.status);

Uploading Files

Use the OpenDrawing method of your WebDAV client by passing the path of the drawing for opening the drawing.


SWFUpload is a JavaScript/Flash library, which gives you the option to add an Upload button to your HTML. The Flash code communicates with the .js code using Flash's ExternalInterface class


Same Origin Policy and Simple PHP Proxy

As part of the basic security model of the Web, sites cannot usually make requests to pages on other domains. The same origin policy prevents document or script loaded from one origin from getting or setting properties of a document from a different origin. Because of this issue, you cannot send WebDAV requests to a server that does not reside in the same domain as the .js file.


To workaround this issue, you can use a simple PHP Proxy. The proxy should reside in the same domain as the client. Requests will be sent to the proxy, which in turn forwards the requests to the WebDAV server and returns the response to the client. The following line in the .php file defines the real WebDAV server address:


$real_destination_host = "";

Ensure that your server is configured to run .php files.

Contact Us
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
Invalid characters found