Friday, September 30, 2011

[Revit Server]– How to get a listing of all Revit Server projects through the REST interface

I’ve been writing some code that utilizes the Revit Server REST API, and in particular, I’m working on a HTML replacement for the Revit Server Admin page, which is currently written in Silverlight. More details on that will come (and will be included in my AU virtual class), but for now I ran into a bit of a stumbling block that others may encounter.

The REST API has an endpoint that lets you list the contents of a certain folder. This endpoint requires a GET request to the path ‘/{folderpath}/contents’ with folderpath being the path of your folder, for example a request to ‘/My_Project/contents’ would list the contents of the My_Project folder. But how do you find out that there is a My_Project folder in the first place? You need to get a listing of all of the folders underneath the parent folder on the server, but how would you do that? You can’t send you request to ‘/contents’, as you are missing the folder path section, and thus it’s not a valid endpoint according to the API. I tried a number of different combinations of URL’s before I finally found one that seems to work.

To get a listing of all the folders underneath the parent folder, send your GET request to:

‘/ /contents’

That is, use a space instead of a folder path, like so:

http://localhost/RevitServerAdminRESTService/AdminRESTService.svc/ /contents”

This will be treated as if it is the root folder, and will list the folders underneath that.

No comments: