Posted on:
Categories: Office 365;SharePoint
Description:

​So I was tasked with creating a SharePoint-hosted add-in that goes to Delve and retrieves only the current user’s boards. Delve boards are user created, dynamically or using previously created boards; oddly enough, it’s also synonymous with adding a card to favorites. If you go to Delve, Delve boards are currently located to the left of the screen, under the People section.​


Because it’s SharePoint-hosted, we must use Javascript for any logic. There are plenty of articles on the internet about how to retrieve Delve boards using the REST API and Javascript. Most of them will tell you to use the query string:​

 

'Path:TAG://PUBLIC/?NAME=*'&Properties='IncludeExternalContent:true’

 

The "Properties" part is what returns the Delve boards; you must specify IncludeExternalContent set to true. Without it, the code won't return any boards.

At first glance, the task is already done since you can just follow the guides and be done in a day or so. Easy, right?

Turns out, the answer is "No".

According to this Microsoft post:


 So while this addresses the privacy issue of documents on public boards, this does not help when using the Delve API. Meaning, because the boards are public, when you use the API to retrieve Delve boards, it returns EVERYONE’s boards, not just the ones that show up in your Delve. 

If you search around, you’ll quickly see no one talks about getting the current user’s Delve boards, just “how to get Delve boards” in general or specific boards with known names. Nor does any blog talk about using multiple Properties, only multiple SelectProperties.

But since Delve uses Office Graph in the background, so we can use that as a hint. 
Querytext='IsDocument:1'&Properties='GraphQuery:ACTOR(ME)'&SelectProperties='DocId,WebId,UniqueId'
Using GQL (Graph Query Language), we can get a bunch of things from Office Graph, EXCEPT user’s Delve boards. The snippet above will retrieve the current user’s cards, and cards only. Dead end there.
 
Unfortunately, after much research, no one has actually ever combined the two and wrote about it. Turns out, there was a very simple way to retrieve the boards; and it’s not tacking on more and more roundabout logic.
 
Looking at the query string for Delve boards and the GQL, you can see they are extremely similar. A closer look shows we should do something with the “Properties”, which, surprisingly once again, no one has inserted more than once. And so the proper syntax for using multiple properties took a little ingenuity and some trial and error, but ultimately, if we include the GQL actor ME as part of the REST API call, we can get Delve boards that belong to the current user. 
"'Path:TAG://PUBLIC/?NAME=*'&Properties='IncludeExternalContent:true,GraphQuery:ACTOR(ME)'";