Skip to content
Sep 7 / Michaël Hompus

Pitfall: Using the SiteData WS to get the SiteGuid

When you want to use the PSI interface you need to have a PSContextInfo object. Inside a Project Server event this will be provided so you don’t need to worry about it’s contents (except when you want to impersonate as a different user). But outside the event you will need to create one from scratch.
One of the properties you need is the SiteGuid. According to the SDK you can get this value in your code using three different methods:

  1. Hard-code the Guid (Not very flexible)
  2. Use the Windows SharePoint Services SPSite.ID property in the Windows SharePoint Services (Very heavy on resources)
  3. Call the sitedata web service with the PWA URL (The best solution if you ask me)

I use the third option in my application, but it returned the wrong Guid. After some debugging I finally found the problem, I requested the URL “http://localhost/PWA/” and there I made my mistake. The trailing / results in getting the Guid of the root site, not the PWA site!

I’m sure I’m not the first one falling in this pitfall, but I’m writting this to prevent you from doing the same. :)

Leave a comment


*