Retrieving posts from blogs available in Delve with Office 365 REST API

Office 365 evolves every day and among the latest developments, Delve has been enriched with a new feature that allows users to create blog posts in a much simpler way that the old SharePoint blog.

If you access a user profile from Delve, you can see all the posts for this user as you can see on the screenshot below.

Delve - Blog HomePage

But what happens if you want to get an aggregated view of all posts from all users on your tenant ? At this time there’s no feature like that in Delve or even in Office 365, but you can create your own.

In the same way that there’s no feature in Delve to view all posts in a single page, there’s no official API for now to achieve our goal. But in many cases, there’s a solution based on the search engine 😉

Each posts created in Delve use a specific content type. If we submit a search query based on that content type, we’ll be able to retrieve all posts in a simple and fast way.

As a reminder, to submit a search query in Office 365, you can send a POST request to the following URL with a well-formatted HTTP body.

https://tenant.sharepoint.com/_api/Search/PostQuery

As mentioned previously, we want to retrieve only blog posts based on the content type. The body of our search request should be something like :

{
  request = {
    Querytext = "ContentTypeId:0x010100DA3A7E6E3DB34DFF8FDEDE1F4EBAF95D00B0046F2796B8374B872064182468FA7F",
    RowLimit = 10,
    SelectProperties = (
      Title,
      Author,
      Created,
      DefaultEncodingUrl,
      Path
    ),
    StartRow = 0,
    Timeout = 30000,
    TrimDuplicates = True
  }
}

As you can see above, we specified that only few properties (title, author, creation date…) will be returned in the search result.

It’s an important thing to know. All parts of a blog post (subtitle, body, cover image…) can’t be retrieved using a search request because they are not indexed by the search engine.

Indeed, content parts of a post are not stored in a list, like we generally do in SharePoint, but are serialized to a file in JSON. If you want to know what’s the URL of that file, you just have to read the value of the DefaultEncodingUrl for each items in the search result.

The value should be something like the URL you can see below (each post is a file with .pointpub extension) :

https://tenant.sharepoint.com/portals/personal/katiej/pPg/My-new-blog.pointpub

Now that we know what’s the URL, you are able to read the content of each post. At this time, there’s no documentation about the JSON format used in this file so it’s pretty difficult to understand and to use.

If you want a sample of one of that files, take a look below :

{"Version":"1.0","PostType":1,"Title":"My new blog is available","SubTitle":"My First Blog Post","ThumbnailSource":"#315f7e","Author":"anonymous author","ControlData":{"cid144411757865295382":{"Version":"1.0","IsInternalControl":true,"ControlName":"ImageHeaderControl","ControlType":4,"DataContext":{"ImageControlSize":12,"ImageSourceType":3,"ImageSource":"#315f7e","CaptionText":"","Title":"My new blog is available","Subtitle":"My First Blog Post","Author":"Katie Jordan","PublishDate":"Sun Oct 18 2015 08:04:38 GMT+0200 (CEST)","__type":"ImageHeaderControlDataContext"},"__type":"ControlData"},"cid1444117578747883681":{"Version":"1.0","IsInternalControl":true,"ControlName":"RichTextControl","ControlType":0,"DataContext":{"Subtype":1,"Value":"\u003cp\u003e​A new feature is available on Delve and now you are able to create your blog.\u003c/p\u003e","NoDefaultValue":false,"__type":"TextControlDataContext"},"__type":"ControlData"}},"ControlMap":{"Rows":[{"Columns":[{"ControlId":"cid144411757865295382","HasChildren":false}]},{"Columns":[{"HasChildren":false,"ControlId":"cid1444117578747883681"}]}],"GridSize":12,"__type":"ControlMap"},"__type":"PersistedPostModel"}

But if you only want to enumerate posts, with their title, author, creation date and to redirect the user when he clicks on a link, you have all you need to achieve this goal with a simple search query.

To redirect the user to the web page corresponding to the post, you just have to read the value of the Path property. It will be something like that :

https://tenant.sharepoint.com/portals/personal/katiej/_layouts/15/PointPublishing.aspx?storyid=1

Now you are able to retrieve all blog posts available in your Office 365 tenant. But if you want to retrieve posts for a particular user, you can change the search query to add supplementary filters (e.g : use the AuthorOWSUser property).

I just hope that Microsoft will offer in a near future, an API to simplify the way we can retrieve data, especially the content of each post.

Advertisements

10 thoughts on “Retrieving posts from blogs available in Delve with Office 365 REST API

    1. dbrabenDavid Braben

      Try putting the following in at the beginning of your query if you’re using OpenGraph to do the search:
      /_api/search/query?Querytext=’STS_List_Posts’&Properties=’GraphQuery:

      It uses the Blog Post Content Type.

      Like

      Reply
      1. dbraben

        Just realized our OneDrives are switch off for security reasons but the above Content Type does seem to work but no results because of the Security I think:
        /_api/search/query?Querytext=%27ContentTypeId:0x010100DA3A7E6E3DB34DFF8FDEDE1F4EBAF95D00B0046F2796B8374B872064182468FA7F%27&Properties=%27GraphQuery:ACTOR(ME\,%20action\:1001)%27

        Like

        Reply
  1. Pingback: Office 365—monthly Dev Digest for November | nokipedia.com

  2. Pingback: Office 365: Monthly Dev Digest for November | Spreadsheet Excel

  3. Pingback: Office 365—monthly Dev Digest for November | Alt-Tech Inc.

  4. Indy

    Great post! Exactly the info that I was looking for to get me started. I used the content type that you stated above in a content by search web part to search for delve blogs and it brought back my users posts! Although, I had to trim down the content type id a little before it started working. Trimming it down to ContentTypeId:0x010100DA3A7E6E3DB34DFF8FDEDE1F4EBAF95D00* helped bring back results.

    Liked by 1 person

    Reply
  5. FirstShasta

    I see you don’t monetize your website, don’t waste your traffic,
    you can earn extra cash every month because you’ve got hi quality content.

    If you want to know how to make extra bucks, search for: Boorfe’s tips best
    adsense alternative

    Like

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s