Retrieving the ProjectUID of a workspace using _api REST interface
By blurg64
Project workspaces are awesome. There I have said it. But one thing that has always frustrated me and other users is how hard it is to determine what project the workspace is linked to. The only reliable way of determining the ProjectUID is to look in the Property Bag of the site where Project Server stores the association. There are a couple of tricks that will let you find out the ProjectUID, one of them being developing a custom web part like I did a while back, or using the CSOM in 2013 as Giles Hamson posted a while ago,
But there is an easier way, thanks to the new _api REST interface.
With this new interface you can expose all aspects of the SharePoint site including all the web, site and lists. However the coolest thing is that you can expose values from the Property Bag directly, meaning we can get the ProjectUID of the site with a simple URL call which you can either use in your JavaScript code, or call it directly from a workflow.
The URL looks like this…
https://mytenant.sharepoint.com/sites/pwa/New%20Project/_api/web/AllProperties?$select=mspwaprojuid
if you break down there are three components…
The first component is the URL of the site we want to get the ProjectUID from.
The second component is the _api call we wish to make, in this case we are retrieving the AllProperties of the web object.
The third component filters the AllProperties to only retrieve the MSPWAPROJUID property, which is where the ProjectUID is stored.
When you open that url in the browser, you receive the following XML back from SharePoint containing the ProjectUID.
Of course you are not limited to just the ProjectUID, removing the filter component from the URL will retrieve all the properties of the Project site including the URL of the PWA site it is associated with (PWAURL).