Monthly Archives: October 2015

NSURLSession/NSURLConnection HTTP load failed when trying to stream an Office 365 Video on iOS 9

Yesterday, I was playing with Office 365 Video and I wanted to be able to play/stream videos from Office 365 into an iOS app.

The first step to be able to read a video was to retrieve the streaming URL of that video in Azure Media Services (which is used behind Office 365 to offer streaming capabilities).

It’s pretty simple using the Office 365 REST API :'01234567-abcd-cded-1234-1234567890ab')/Videos(guid'01234567-abcd-cded-1234-1234567890ab')/GetPlaybackUrl(0)

When you execute that request, you retrieve the URL to play/stream the video from Azure Media Services in HLS format (HTTP Live Streaming). This URL should look something like :

To play/stream the video into an iOS app, you can use the built-in video player (AVPlayer) which is compatible with HLS format. To do that, you just have to write few lines of code :

let URL = NSURL(string: "...")  // Put here the URL retrieved from GetPlaybackUrl
let playerViewController = AVPlayerViewController()
playerViewController.player = AVPlayer(URL: URL!)
presentViewController(playerViewController, animated: true, completion: nil)

If you run this code on iOS 8, there’s no problem and everything should work fine. But if you run the same code on iOS 9, it should throw an exception like that :

NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802)

You have to wonder why the same code don’t work on the last version of iOS. The answer is quite simple : App Transport Security (ATS).

In iOS 9, there are new security mechanisms that have been implemented to ensure that, when an app uses network communications, the traffic is encrypted to ensure confidentiality.

But if you look the URL of the video, it uses HTTPS so the traffic is encrypted. Then why an exception was thrown ? It seems that the ciphers used to encrypt the traffic are considered as unsafe by iOS 9.

What to do to be able to play/stream the video in that case ? It’s possible to configure how ATS works by modifying the info.plist file of your app.

There are many ways to do that and the most easiest is to add the following key/values :


For in-house apps or development purposes, it’s very useful but not secured because ATS is completely disabled. If you read Apple’s documentation, it also could be a reason to reject your app if you want to publish it on the AppStore.

If you want to manage more precisely which URLs can be used without problems with ATS, you have to add exception domains in your info.plist as you can see above :


With these settings, we configure ATS to allow more ciphers to encrypt HTTPS traffic, for two domains (and all sub-domains) used by Azure Media Services to stream videos.

If you prefer to use the editor available in Xcode to edit your info.plist, rather than manually editing the XML file, you just have to add key/values like :

Office365 Video - App Transport Security

Now if we execute our app, we are able to play/stream the video without any exceptions. 😉

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.

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 = (
    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) :

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 :

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.

Record of visitors and awarded as Microsoft MVP

Yesterday was a great day for me because two important things happened in the same day.

Firstly, for the 6th consecutive month, the record of visitors on this blog was beaten.

In September 2015, you were 780 to visit this website with 1,100 page views.

Record of visitors - September 2015.

It’s a great pride for me to see that you appreciate the work done here, and that you are more and more numerous each month to read this blog and its content.

Secondly, probably in recognition on the work done in the past months, I’ve been awarded by Microsoft as MVP (Most Valuable Professional) on Office Development.

Microsoft MVP Award

If you don’t know what are Microsoft MVPs, this is what they say on the official website ( :

Microsoft Most Valuable Professionals, or MVPs, are community leaders who’ve demonstrated an exemplary commitment to helping others get the most out of their experience with Microsoft technologies“.

It’s a great honour for me to be recognized for my work but it’s also thanks to you that this could have happened.

So I would like to thank all of you, visitors of this website, and Microsoft people who appreciated what I’ve done in the past months.

I hope this will continue in the next months/years with a growing success for all of us 😉