I have a Revit Server App on the go and part of it is retrieving thumbnails of the models held on the servers. The Revit Server 2013 API Reference does give a brief explanation of the thumbnail query on page 20 but falls short of giving a code example. So reading through some of the more general REST forums I came up with the code below specifically on how to extract the Image from the response. But it Errors out on the commented line. Anyone any sample code or ideas why it might be erroring? Other types of query (contents, directoryInfo, etc) work OK.
Cheers
Graham
// Create request (model in root folder MyModels/Sector) WebRequest request = WebRequest.Create(
"http://serverName/RevitServerAdminRESTService2013/
AdminRESTService.svc/MyModels|Sector|model01.rvt/t...");
request.Method = "GET"; // Add the request headers request.Headers.Add("User-Name", "Test"); request.Headers.Add("User-Machine-Name", "Test-PC") request.Headers.Add("Operation-GUID", Guid.NewGuid().ToString()); // Read the response // Next line fails // Error 500 Internal Server Error - The server encountered an unexpected condition which
// prevented it from fulfilling the request. WebResponse response = request.GetResponse();
Stream stream = response.GetResponseStream();
return new Bitmap(stream);
Hi Graham,
While I never used this specific call, I asked a Revit Server engineer, thinking that I can request a sample code. He says that there is no problem in your code. The code is working at his side.
He also says that “500 Internal Server Error” normally means this is because that the server/model gets into an abnormal state. You may want to take a look at AdminRESTService.log.
He also suggests to check whether the code work on other models. Also to check whether other APIs work. (which I think you are saying that other API works with the same model above?)
I hope this gives you some idea to look further.
Thanks for that Mikako, much appreciated. Your information was enough to figure out what was wrong. I attach the AdminRESTService.log file from one of the servers which suggests that the Revit.Thumbnail20.dll file cannot be loaded (module). Why i don't know yet. It was a standard revit server install. I'll look at it in the morning. You've put me on the right path anyway!
Cheers
Graham
I have now tested this on several sites and several servers and get the same error in the respective AdminRestService.log regarding Revit.Thumbnail20.dll (see attachment in previous post). Even when i try re-registering the dll an error popup says:
"The Module Revit.Thumbnail20.dll failed to load. Make sure the binary is stored at the specified path or debug it to check for problems with the binary or dependent .DLL files. The specified module could not be found."
All other aspects of my program work well without any problems so i suspect there is an issue with Revit.Thumbnail20.dll that needs fixing. The file version is 2.0.0.0 dated 21 Feb 2012 9:28pm.