Presently sponsored by: ScriptRunner - Get your free PowerShell Security e-Book!
This article is part of a series about “Getting started with Office 365 development”.
In recent announcements from Microsoft, some key takeaways were the consolidation of technologies in the Office 365 category. Meaning that focus shifts a bit away from individual products in the cloud and into a collective umbrella. This has been known for a long time, given Microsoft’s dedication to the cloud-first approach for new features and tools. With Office 365 we now have new and updated API’s we can develop with in order to access information Exchange Calendars, E-mails, Contacts, SharePoint Lists and AD information.
As of this writing, the API’s are in Preview but updates will most likely come with a high update cadence. Microsoft have launched a new site for getting started with the new Office 365 API’s, located in the Office Dev Center, which will be an awesome resource for you to get started with Office 365 development for real.
Please note(Updated: May 13th 2014)
As good friend and former Microsoft MVP (Now Microsoft employee) Jeremy Thake mentions in the Office blog, there are these project types with support for the Office 365 API tools:
- .NET Windows Store App
- .NET Windows Store Universal App
- Windows Form Application
- WPF Application
- ASP.NET MVC Application
- ASP.NET Web Forms Application
- Xamarin Android and iOS Applications
- Multi-device Hybrid Apps
As of the last update of the tools on May 12th and as of this writing, there’s now additional project types supported, and they are all listed in the list above.
Configure your development environment
In order to be able to work with the APIs for Office 365, you need to install a new Visual Studio extension. The extension called “Office 365 API Tools” and should be installed on your development environment. Visual Studio 2013 is a requirement.
Download and install the package on your development environment and make sure that the extension is activated in Visual Studio:
Okay great, that wasn’t the hard part – let’s move on and add a connection
Create a new ASP.NET MVC Project
Since my samples will be based on the ASP.NET Project type (MVC) I will kick things off by creating a new project called “Zimmergren.O365.MyContent“:
In the dialog for choosing your template, you must select MVC:
Okay, so the project is created and we have an empty base project set up – now what?
Add a Connected Service (Office 365)
Next part is to make sure we can connect to the Office 365 API’s and play around with the tools we’ve installed to aid us in the quest for quicker and more reliable development. In order to get things started, you simply right click on your project and choose “Add” – “Connected Service…“:
You will reach a dialog where you are prompted to Sign in first if you haven’t done so. Do this by clicking on the “Sign in” button in the dialog:
By doing this, you will be prompted to sign into your Office 365 subscription. In my case I’m choosing to sign in with my development account for Office 365, since I’ve got all services running there and can make proper demos and samples towards that tenant.
Once you have logged in, you will need to select which service you want to connect to. In my quick test I’ll be hooking up the Exchange service (“Mail” below):
You will be prompted for configuring permissions. I’m not going to talk much about the permissions in this post, but we’ll get into that later, so for now you can just select “Read“on all of the sections:
Once this is completed, your Visual Studio project has been very kind and auto-generated code samples for your MVC project. It has created samples for Exchange under the “Views” folder in your project. By hitting F5 and just launching your new project and navigating to [rootsite]/ExchangeSample you will get to the point where you can see the results of the connection between your app and the Office 365 tenant:
The first time you click on any of the sample buttons, which in turn connect to Office 365, you are prompted to sign in and the Microsoft login dialogs are displayed:
Then once you are authenticated properly, the app will gladly display any and all information that you request through code:
That wasn’t very hard to set up – all you really need is to have an Office 365 account (preferably a developer account) and Visual Studio 2013 with the Office 365 API Tools installed.
From that point, you simply hook up the connection to Office 365 from Visual Studio and you are good to go. Explore the world, join the adventures of Office 365 development and utilize these new API’s in any way you desire.
This concludes part 1 in this article series and should only be seen as an introduction to the Office 365 API tools to get you set up. In the future posts I’ll dig into more details about how to retrieve different data and customize your applications etc.