Register your application to work with Office 365 – Part 2

Learn how to register your application to work with Office 365

In this article, I will continue from where we left in part-1 to register an application to work with Office 365 using the Microsoft App Registration Portal.

This is part-2 of the two-part series, I suggest to read the part-1 here first before continuing.

The objectives of this article are:

  • Alternate way to register your application
  • How to run sample code
  • Access your registered application from MS Azure Portal
  • Application flow

Alternate Way to register:

You can also register application from the “Quick Start” page which is shown immediately after your login to App Registration Portal

Quick Start.png

Click on the “Web” link, you will be shown following:

“Web” link.png

Enter the application name and your contact email, then click on “Create”. I entered “CSCorner” in the application name:


You will be shown a success message and asked for redirect URL:

redirect URL3.png

For a quick demo, enter the same URL we entered above http://localhost:57329/AfterLoginPage and click “Save”.

How to run sample code:

After clicking “Save” button in above section, you will be shown a sample code section:

sample code section.png

You can see that your application’s ID and redirect URL are already there. This is a simple HTML and JavaScript code which you can quickly integrate into your application to redirect users to Microsoft for login.

Copy the script to any HTML page header section or create a new page in sample ASP.Net web application we created above.

Scroll down on the portal registration page, you will see code for HTML button:

HTML button.png

Copy this code to body section of new HTML page you created. Save and run the page in browser.

If you create a new ASP.Net web form, then mark to page as startup page and run your web application.

In both the cases, it is necessary that the http://localhost:57329 site is running so that Microsoft can redirect your application to that page.

Both the before login page and after login page of sample web application are attached with this article. You need to add them to your sample application to test demo. Don’t forget to change “clientId” and “redirectUri” values in your page:

sample application.png

Run the application or browse the HTML page you created:

Run the application.png

Click on the Sign in button. You will be shown a login page from Microsoft:

login page from Microsoft.png

Enter your Microsoft login and password, click on “Sign in”.

You may be shown a page like shown below asking for your permission to give grant to application if you are logging in for the first time. Please note this is not the actual screen shot of my application, I have taken it as reference from Microsoft site:


Image source: Microsoft

You will be redirected to the page mentioned in “Redirect URL” setting:


Congratulations! You have implemented the authentication with MS Identity stack. Remember you must write code for fetching data from MS Graph API or any other Office 365 APIs. This article covers only registering your application with MS App Registration Portal and demo of logging in using Microsoft credentials.

Access your registered apps from MS Azure Portal:

The applications you registered here are also accessible from MS Azure Portal.

To do so, login to MS Azure portal with the same login you used to register your app on MS App Registration Portal.

Once you are logged in, find and click on the link “Azure Active Directory” Azure Active Directory in left pane:

Azure Active Directory2.png

One more menu will open, find and click on the link “App registrations”App registrations:

App registrations2.png

Alternatively, without clicking on that link, Azure portal will show you the registered apps on the dashboard:


Either click on the “App Registrations” menu on left or click on the “App Registrations” web part in dashboard.

You will be shown following screen:

App Registrations3.png

You will not see your registered app directly here, Click on the “Microsoft Application Console” link.

Azure portal will redirect you to a login page, once your login is successful, you will be redirected to “My Applications” page of MS Application Registration Portal:

Microsoft Application Console.png

Application flow:

If you really want to develop an application and fetch some data from Office 365, you will need to do much more than just register an application in the portal.

Here is the complete application flow for your reference, you can follow it step by step to develop an application which will access data from MS Graph API or Office 365 APIs:

  • Register the application on Microsoft App Registration Portal:
  • Configure the project with ID & key or copy and paste the sample code from portal quick start
  • Authenticate the user and get an access token
  • Call Microsoft Graph API / Office 365 API(s) / Other MS Cloud API
  • Parse the result, show the result to application user

I will cover these steps in detail in a future article, until then – Happy learning!


Header Image Credit: C# Corner

Register your application to work with Office 365 – Part 1

Register your application to work with Office 365 using the Microsoft Application Registration Portal.

In this article, I will explain how you can register your application to work with Office 365 using the Microsoft App Registration Portal.

This is part-1 of the two-part series, you can continue to read another part here.

These are the objectives of the article:

  • What is Microsoft Application Registration portal?
  • Why you should know about it?
  • Overview of components in Microsoft Application Registration portal


If you are developing an application which is going to work with Microsoft Office 365, like fetching data using MS Graph API or any other Office 365 API, then you will need to register your application with Microsoft first.

Your application users need to be authenticated in Microsoft identity stack first before your application can fetch data using the MS Graph API or any other Office 365 API on their behalf.

 What is Microsoft Application Registration portal?

MS Application Registration Portal is the website where you can go and register your application so that it can work with MS Identity stack and you can get access token to get data from Microsoft APIs.

Here you can:

  • Register new applications
  • Modify existing application for – access permissions, redirection URL, etc.
  • Generate keys
  • Set up application profile

 Why you should know about Microsoft Application Registration portal?

Apart from the purpose stated above, if you want to eliminate managing user name and passwords in your application on your own and let users log in with Microsoft work or school or personal account, then you can delegate the work of authentication to Microsoft. Users can login to your application using Microsoft Identity stack.

By supporting sign in with Microsoft identity stack, your application can have single sign on with Windows and Microsoft cloud applications, can protect your users with the same technology and investments used to protect Microsoft’s users, and can programmatically access information and insights about users via the Microsoft Graph API or other Office 365 APIs.

Any application which wants to use the capabilities of MS Identity stack must first be registered in MS App Registration portal. Here you will be able to get an App ID and redirect URL along with secret code which is necessary to make your app work with Office 365.


At the Application Registration portal, you will generate an App Secret which will be shown to you only once. Please retain that App Secret, as you will need it to run your app. If you forget it, you will need to restart the registration flow again. There is no way to get the App Secret again.

Cross-platform support:

It supports registering application for iOS, Android, web, and more:


Access data from Microsoft APIs

Access user data inside the enterprise — get an Office 365 user’s calendar, mail, and contacts. The registration in MS App Registration Portal satisfies the basic authentication requirement, you must write code specific to the Office 365 or any other Microsoft API.

Wide use

The Microsoft identity stack has been battle tested by some of the biggest companies in the world.

Using MS Identity stack, you can offer one-click sign in to:

  • Around 85% of the Fortune 500 companies’ users
  • Around 85M monthly active users on Office 365 commercial
  • Around 400M monthly active users

What you will need to register?

You can register using your Microsoft work or school or personal account. You can use your MS Office 365 developer account or windows live account to register your app.

If you are developing for Office 365 and you want to create a developer trial account, read my article here in which I have explained in detail how you can get a free Office 365 account for 1 year.

Where you can register your application?

You can visit the MS App Registration portal here, and then click “Register your app >


If you are not already logged in and you click on “Register your app >” link, then portal will first redirect you to login page:


If you enter your Office 365 developer account, then you will be shown a screen like below to enter password:


Let’s see different components in MS App Registration Component

Once you have entered your correct password and successfully logged in, you will be shown the following screen:


You can see here the options to register an application for iOS, Android or Web.

If you click on the “My Applications” link on top right, then it will show you any existing application registration in current login id:

my apps.png

Application name and its GUID app id are masked in above screen shot by me for security purpose. You can also see “Add an app” button on top right in this screen. Click on that button and you will see a popup to register new application:

register new application.png

Enter the name of your application and click “Create application”. I entered “CSharpCorner” and clicked on the button:

Create application.png

Portal will create an application named “CSharpCorner” for you. I have highlighted the application name. I have also hidden my email id and application id which is unique id for your application. Have a look at different options available in this page. One by one I will cover those below.

Also, note the message displayed below application name header “CsharpCorner Registration”:

CsharpCorner Registration.png

It says that the application “CSharpCorner” will be registered in the MS Azure active directory instance which manages the login account with which you have logged in. What it means is covered later in this article.

For the scope of this article, “Azure Active Directory” is not covered in any more detail but I suggest you read about it on Microsoft Docs here.

On the same page, note that a section for assigning Microsoft Graph permissions:

Microsoft Graph permissions.png

Further down the page, you will see some other profile settings:

profile settings.png

You can add logo for your application, and URLs for your application’s home page, ToS, Privacy, etc.

Still further down the page, there are some other advanced options, along with save and cancel buttons:

advanced options.png

“Application Secrets” section:

Scroll to the “Application Secrets” section.

Application Secrets.png

Click on the “Generate New Password” button to create a password for our application. Portal will generate new password for your application and show in a popup:

Generate New Password.png

Note that the password will be shown to you only once now and there is no way to see this password again. So, it is necessary to store this password somewhere safe so that you can use it in your code later.

You will use this password along with the “application id” of this application to make your users authenticated by Microsoft.

Click “Ok” button and you will see that Portal shows you masked password:

masked password.png

Mostly in programming you will use the application id and password combination to redirect your users to authenticate on Microsoft site. But if you want to create a private key/certificate it can be done here too.

Click on the “Generate New Key Pair” link:

Generate New Key Pair.png

Enter the password and click “Ok”. Remember the password used to create the key, store it somewhere safely. Also, within seconds when the private key is ready, Portal will show you message to save it:

download the file.png

Click on “Save File” and then click “Ok” to download the file.

Once the file is downloaded, you can go to the download location and see the file:

download location.png

Double click on it to import; a certificate import wizard will be shown to you:

certificate import wizard.png

For the scope of this article, the certificate import wizard is not covered. You can explore it on your own.

“Platforms” section:

Now go back to the App Registration Portal, scroll to the “Platforms” section and click on “Add Platform” button:


You will see the “Add Platform” popup:

Add Platform.png


Web application, Native application and Web API platforms can be added here. Click on “Web”. The following section will be added to the page:

Web application.png

The most important setting here is the “Redirect URL”:

Redirect URL.png

It’s the URL to which the user’s browser will be redirected after Microsoft authenticates the user. It should be a URL of a page in your web application which you want to show once user completes authentication with Microsoft, like a landing page.

For showing you a demo, I have created a sample ASP.Net application on my PC and taken its local URL which I will enter in the “Redirect URL” textbox:


Redirect URL 2.png

Similarly, you can also click on “Add Platform” again and select “Native Application” this time:

Native Application.png

You will see the “Native Application” section will be added to the page:

Native Application2.png

Once again click on “Add Platform” and select “Web API”:

Web API.png

The “Web API” section will be added to page:

Web API2.png

I will not go into details of “Native Application” and “Web API” sections.

You can delete these two platforms if you added for testing, because for demo I will show you only “Web” platform.

“Microsoft Graph Permissions” section:

In this section, the permission to your application when it communicates with MS Graph API is decided.

To understand better, read the following extract from Microsoft Docs:

By defining these types of permissions, the resource has fine-grained control over its data and how the data is exposed. A third-party app can request these permissions from an app user. The app user must approve the permissions before the app can act on the user’s behalf. By chunking the resource’s functionality into smaller permission sets, third-party apps can be built to request only the specific permissions that they need to perform their function. App users can know exactly how an app will use their data, and they can be more confident that the app is not behaving with malicious intent.

By default, there is only one “User.Read” permission which is the simple most read-only permission:


Click on the “Add” button besides “Delegated Permissions”. You will be shown the “Select Permission” popup:

Select Permission.png

It’s up to you which permission you want to give to your application based on the type of work you are doing in it. Never give unnecessary or all permissions to application as it may result in some user data loss inadvertently. Select only those permissions which you actually need in your application. Let’s say your application will send and receive emails, then select the Mail.Read and Mail.Send permissions.

Click “Ok” and see the permissions are there on the page:


Scroll down to the bottom of the page and click on “Save” to save the changes.

There is also another way to register your application which I will cover in part-2 of the series.

To read how to register application in alternate way, how to see registered applications in MS Azure Portal and for a quick demo, check my part-2 article here.


Header Image Credit: C# Corner

Introducing The .NET API Browser

Brief intro of Microsoft Dot Net API Browser

Microsoft has launched .NET API Browser as a part of its effort to provide a unified.NET reference experience on

It is a way to standardize how the developers can document, discover and navigate .NET APIs at Microsoft website.

.NET API Browser can be viewed here

You can have a first look below:

If you expand “All APIs” lookup, then you can see the list of all Microsoft APIs which you can select from:

At the bottom of the API Browser, there are some mainly used APIs already listed under Quick Filters. You can click any of them to quickly navigate to API’s documentation.


Once you select any APIs name from the drop-down, then you will see another drop-down with further selection for API version.


Once you select any API (click on the API name under name” column), you will be shown the documentation of that API with its definition, classes, structs and interfaces.


You can change the namespace and API version from the same page, using the drop-downs on the left top side.


 You can also change the language and theme from the top right side.


There are two theme selections available:


In the months to come, Microsoft is going to add more SDKs to this experience. I am missing Office 365 and Microsoft Graph APIs reference here and I hope, it will be added by Microsoft in near future.

Now go to .NET API Browser and explore some documentation.
Happy learning!!!

Note: This article was published by me at C# Corner here.

Host Your Website On Github Pages For Free

How you can host your website for free using Git Hub pages

This article assumes you already know what GitHub is, you know how to work with GitHub, and you have a repository in GitHub having some web front-end. If not, please go to GitHub and get your hands dirty!
In this article, I will quickly introduce you to GitHub Pages, using which you can freely host your websites, straight from your repositories on GitHub. Isn’t this fantastic?

This article is a brief introduction to setting up your website using GitHub Pages, but it does not cover each and every detail about GitHub Pages.

Ever wondered if it was possible to quickly setup a website and host it for free somewhere? Ever wondered if there was a way to just upload your code on a repository and directly show demos to your clients over the internet?

Think no more! With GitHub Pages (GH-Pages in short!), you can now host your website directly from your GitHub repository and that too for free!

Any of your repositories on GitHub which has a web front-end can be quickly converted to a running website in a matter of minutes using the feature called GitHub Pages brought to you by GitHub.

It has some following limitations too, but I don’t think it will stop you from using GitHub Pages for your next client demo.
  •  Limit of 1 GB for source code repositories.
  • 100 GB per month bandwidth limit
  • 10 builds per hour

You can browse your website on GitHub Pages using the following URL.

You need to replace your username and repository name before you fire a request in your browser. So, let’s now quickly see how you can set up a GH-Pages website from your repository.

First of all, you should have an index.html file in your repository. If not, then quickly create a new index.html file and commit it.

Second, you need to do settings in your repository that from which branch your website should be rendered. For doing that, select your repository in GitHub. On the top right, you will see a “settings” link (just below the repository name).

Once the settings page is loaded, scroll down to the “GitHub Pages” section under the “Source” label, select the branch of your repository from which you want the website to be rendered. The default selection will be “none” – meaning your repository is not currently enabled for GitHub Pages.

Let’s say you have selected “master” branch. After branch selection, a “Save” button will appear besides branch selection lookup. Click on “Save” to save your changes.

Once you click on “Save”, immidiately GitHub creates a website of your repository from selected branch and it is readily available. Note down the url given by GitHub – you will use it to visit your website.

Simple, isn’t it?

Now, go and browse your website at the URL given by GitHub!

Enjoy! Keep Learning!!!

Note: This article was published by me at C# Corner here.

Installation Of Visual Studio 2017, A Firsthand Explanation

This article tries to give a firsthand and quick introduction to installing Visual Studio 2017, highlighting some of its new features.

Today, Microsoft has launched Visual Studio 2017, the latest IDE for developing “mostly anything” in the Microsoft platform as well as developing apps and Websites, which target Android, iOS and Linux.

If you have already registered for the Microsoft Visual Studio 2017 launch event, then your mailbox may have an email from Microsoft regarding resources related to VS2017, else you can click here to get started with downloading VS2017.

Moreover, if you download VS2017 by March 14, you will get free 60-day access to Xamarin University, which will help you in a great way to enhance your Xamarin skills.

You can choose to install either community, professional or enterprise editions. This article explains the features of the enterprise edition. If you want to know what’s in the different editions, then you can read more here.

If you want to check the installation requirements, you can read more here.

Once you have clicked on your desired edition, the Browser should prompt you to save the installer file.

Visual Studio 2017

Click Save File button to save this installer file to your download folder.

Also, note that once download starts, your Browser will show a “thank you” page with this message related to “Xamarin University”.

Visual Studio 2017

In this article, we are not going to touch anything related to “Xamarin University” but will concentrate only on VS2017.

Meanwhile your installer file may have been downloaded, click on the file to run it. You will be prompted with the message given below.

Visual Studio 2017

Click Yes to continue. You will be prompted with yet another popup, as shown below.

Visual Studio 2017

Click again to Continue.

This release of Visual Studio will show you a new light weight installation approach, which is quite different from the past versions of IDE.

Clicking on “Continue” in the previous popup will show you the installation launch screen given below.

Visual Studio 2017

This is a new “modular” installation experience, where you can tailor VS to install only the components, as per your needs.

You can maximize the installation screen to see more details.

There are 3 tabs here: “Workloads”, “Individual Components” and “Language packs”.


It contains a choice for which type of development work you are going to do with VS2017 e.g. Universal Windows Platform development, Desktop development (with Win Forms, WPF), Web development, Mobile development, Office365 development etc.

If you wish to install a development Workload, you can choose it by clicking on the top right checkbox.

Visual Studio 2017

Individual components

This section contains choices to install some tools, which were previously being installed separately as some “packs”. You can see different versions of .NET Framework here like Azure Cloud Explorer and some other MS Azure related tools like Azure Storage Emulator, Azure Data Lake Tools etc. Some SDKs for Android, Windows 10, Typescript  etc. are also there, where you need to choose the ones in which you are interested in by clicking the checkbox in front of the item.

Visual Studio 2017

Language packs

This section offers some language choices for VS2017. English will be selected by default. Most of you may not need any other language.

Visual Studio 2017
Some more points to be noted here  are given below.

There is no “Select All” feature in this new installation, which I really miss. You must go and manually select the components.

Check the right side of the installation Window and it shows Summary as you go on selecting the features.

Visual Studio 2017

You can expand individual items to see what’s inside that and there are some more choices.

Visual Studio 2017

If you need support of some of these sub-features, you can select them by clicking on the check boxes.

You can change VS2017 location at the bottom of the Window.

Visual Studio 2017

At the bottom-right of the installation Window, you can see the approximate installation size (which changes as per feature selection).

Visual Studio 2017

Once you have explored all 3 tabs and sub-features from the “Summary” section and when you are ready to go, click Install button.

You will be shown the screen, which shows installation progress as VS2017 is getting installed.

Visual Studio 2017
Let the installer do its work. While VS2017 is being installed, go and grab a cup of coffee.

Once the installation finishes, you will be prompted to restart.

Visual Studio 2017
It’s a good idea to restart your PC now, as the installer may have changed many things on your PC. Save your important documents, which may be open, click Restart.

Once restarted, find VS2017 in start menu, or type “Visual Studio 2017” in run prompt. There will not be any shortcut on the desktop.

Once loaded, you will be shown a welcome screen.

Visual Studio 2017

Now, again a prompt is there to choose developer settings and theme.

Visual Studio 2017

Make a selection as per your liking and click Start Visual Studio.


You have installed Visual Studio 2017.

Visual Studio 2017

If you want to read the release notes for VS2017, click here.

Now, go and install the trial version of VS2017 by yourself, write some code, get your hands dirty!

Check for my next article on some new features in VS2017 here.

Note: This article was published by me on C# Corner website here.

Header Image credit: C# Corner

Visual Studio 2017 New Features

In this article, you will be acquainted with Visual Studio 2017 and its new features

Welcome to another article on VS2017. I’m sure that you have already read my article on installation of VS2017. If not, then read it here.

In this article, I will demonstrate some new features of Visual Studio 2017 IDE, which will help a lot in your day to day development.

Creating new project with VS2017

Open VS2017 and you will be shown a welcome page.

There are two ways to create a new project in VS2017.

You can write the type of project, which you want to create in the textbox below “New Project” header.

You will be shown the type of projects as and when you type in the textbox.

e.g. writing “console”:

When you write WPF:

There is also another way to create a new project. Click More project templates link just below the textbox. You will be shown a familiar dialog box to create new projects.

What’s new in Visual Studio IDE

Let’s start by creating a console Application. I will introduce some of the new features in VS2017.

Improved code navigation

After creating a console Application, go to Solution Explorer and right click on the project to add new class.

Let’s say that we are adding new Customer class given below.

Now, save the Customer.cs file and go to Program.cs.

Write Customer in the Main function, press either Ctrl + T (Control key followed by T key) or Ctrl + , (Control button followed by, key).

On the top right, you will be shown a pop-down dialog, which will help you quickly locate the referenced element. Notice that it will quickly launch the “Customer.cs” file too.

In this way, you can have a look at a referenced class and its properties quickly without the need to open the relevant file in IDE. You can simply press ESC key, the dialog, file and both will close.

“Fuzzy” matching

VS2017 introduces a new feature called “fuzzy matching”, which means when you type a name and even if you misspell it, VS2017 will show you the results, which are based on fuzzy match.

To experience it, let’s go to Program.cs -> Main method again.

Type “Cstomer” and see.

VS2017 will automatically suggest you “Customer” class and highlights it for you

Changes in References window

Write the line given below in Main method.


  1. Customer cust = new Customer();


Now, place the mouse cursor on “Custmer” word, press “Shift” + “F12” keys.

You will be shown a new “references” Window, which has been modified compared to “Find Symbol Results” Window in VS2015.

Notice in the “references” Window, there are many new things here like Filtering (on left side), Group by, Search, “Keep Results” button, Sorting and Colorization.

Let’s see each of them one by one.

Filtering references

In VS2015, when you find all the references on a class or property, you will be shown all the referenced results with no option to filter them. Now, in VS2017, you have filtering option in references Window.

See on the left side that there is a drop-down and by default Entire Solution is selected.

You can filter the references; based on which area you want to see and VS2017 will only show you the relevant references.


With the “Group By” feature, you can change how the references are being displayed. It provides you the options given below, which helps you in quickly navigating to the reference; you are looking for,

Let’s say you select “Definition, Project then Path” option and you will see the references group, as shown below.


On the top right section of “references” Window, you can search inside the “references” results.

Keep results

This is a new interesting feature. Remember in VS2015 when you are already looking at one references result and you want to find another class or property reference too. If you search in another class reference, your previous result will be overwritten. You can see only one reference result at a time.

If you press “Keep Results” button on the references Window and you search for another term, then your original result will be preserved and you will be shown references in a new Window.

Let’s say that you create a new “Order” class and reference it from Main method.

Press “Keep Results” button on the references Window of customer results, go to Order class and press Shift + F12. You will be shown references in another Window.

At the bottom of the Window, you will be able to find a tab for “Customer” references too.


You can now click on the results column headers like Code, File, Line, Col and Project to have your references result sorted by these columns, which were missing in VS2015.


Notice the references are displayed in different colors to help you in clear understanding of the references.

Structure Guide Lines

A dotted vertical line now runs between the curly braces to identify scope. If you mouse over the dotted line, then you will be shown the current scope.

Code Refactoring enhancements

VS2017 has improved refactoring a lot to make the code more readable.

Let’s consider some new improvements.

Object initialization

If you have written the code step by step to assign the values to an object’s property, VS2017 refactoring will now suggest you to use an object initialization.

Write the code given below in Main method.

Now, place your mouse cursor on Customer and press Cltr + . (Control key followed by .)

VS2017 will give you a message “Object initialization can be simplified”.

Click on the suggestion and your code will be modified, as shown below.

Also, there are some more such enhanced features, which you can try yourself:

Inline Out variable.

Simplify null checks.

Add missing case(s) to a Switch statement.

And much more

There are many more new features of VS2017 but for the scope of this article, I will restrict to above five only.

Go and install Visual Studio 2017 on your PC to find out more by yourself.

Happy coding!!!

Note: This article was published by me on C# Corner website here.

Header Image credit: C# Corner

Introduction To MS Graph Explorer

In this article, I will explain what is MS Graph Explorer and how can a developer use it.

In this article, I will explain you what is MS Graph Explorer and what you can do with it.

First, let’s start with a quick introduction of MS Graph.

What is MS Graph?

The official MS documentation defines MS Graph as,

“Microsoft Graph exposes multiple APIs from Office 365 and other Microsoft cloud services through a single endpoint, Microsoft Graph simplifies queries that would otherwise be more complex.”

So, in a nutshell, MS Graph gives you a single REST API endpoint which you can call to interact with “almost anything” in Office365. It delegates calls to different Office 365 cloud services via one single endpoint.

Now, let’s learn about MS Graph Explorer.

What MS Graph Explorer is

MS Graph Explorer is a fantastic tool if you want to work with MS Graph APIs or if you are learning to develop with Graph APIs. Consider it as a developer sandbox or a playground where a developer can have firsthand experience of MS Graph APIs.

What you need to work with MS Graph Explorer

MS Graph Explorer provides you default login – a demo tenant with which you can fire some GET calls using MS Graph APIs. But, if you want to explore more and want to also fire POST, PATCH and DELETE calls to MS Graph API, then you will need an Office365 account.


A word of caution here; never play with your live Office365 data or work account here with MS Graph APIs. You may accidentally update or delete some important information. It is advisable to use a test/demo account.

If you join the MS Office 365 developer program here, Microsoft will give you one year free Office 365 developer subscription for non-commercial use with 5 users. You can read more about it in my related article “Office 365 developer program”.

What you can do with MS Graph Explorer

A lot!

MS Graph Explorer gives you a test client to access whatever you can access with MS Graph REST APIs. Using MS Graph Explorer, you can,

  • Access/Modify data from Office 365 and other cloud services like SharePoint online, OneDrive, etc.
  • Navigate different Office 365 entities and traverse the relationships among them
  • Get intelligence and insights from the Microsoft cloud (limited to commercial users only)

In short, MS Graph Explorer is a one stop shop for everything you want to play with, in Graph APIs.

Why you should use MS Graph Explorer

MS Graph Explorer is a great tool to test how MS Graph APIs work. A developer can use MS Graph Explorer to:

  • Test Graph API calling logic beforehand dealing with any endpoint.
  • See what data Graph API gives you back.
  • See how the POST, PATCH and DELETE calls work.
  • See how an entity in Office 365 can be accessed, using which relationship path.

The first look of MS Graph Explorer

MS Graph

The screenshot of MS Graph Explorer with some annotations above is mostly self-explanatory. API version and Request type selections are covered in below sections. I would like to cover some parts which were not mentioned above.

The “History” button

MS Graph

It maintains the history of the API calls you made to the Graph API, and clicking on the history, you can easily go back to that call. Remember, as you make the Graph API calls, the browser URL does not change, so to get back to any of your previous calls, you need to click this button.

When you click on the “History” button, you will see a section as shown below. You can click on any URL request and it will be re-played.

MS Graph

“Request Header” and “Request Body” section

Along with the API endpoint and passing parameters in query string, sometimes you will also need to pass more data to the Graph API.

The HTTP request headers can be specified in the “Request Header” area. Once you click on the “REQUEST HEADER” link, a text area will appear below it,

MS Graph

Similarly, the HTTP Request body can be specified in the area which appears once you click on the “REQUEST BODY” link as shown below. But remember you need to be logged in to enable the link, if you are using demo tenant then the link will be disabled,
MS Graph

Also, in the case of “POST” and “PATCH” verbs selection only, the request body link will be enabled, otherwise it will be disabled. Once you click on the enabled “REQUEST BODY” link, then a text area below it will appear,

MS Graph

Now, go to the service endpoint address bar and type the following URL:

You will see the MS Graph Explorer that will show you a link “INSERT USERS TEMPLATE”.

MS Graph

When you click on the “INSERT USERS TEMPLATE” link, MS Graph Explorer will insert JSON for creating a user.

MS Graph

Do you see now how much MS Graph Explorer makes it easier for you to play with the API calls?

You can change some data from the default text and then hit the “GO” button for the user to be created in your organization’s Office 365 account. Remember to use a test/demo account and not the live account.

If you really pressed the “GO” button, then the Graph Explorer will show you the result in the “RESPONSE” section.

How to fire actual API calls is covered in the section “Let’s try it out” below.

API versions supported by MS Graph Explorer

As of now, MS Graph APIs are only in two versions: V1.0 for general availability, and “beta” for preview. MS Graph Explorer supports both these versions.

You can see the supported API versions in MS Graph Explorer when you expand the “API Version” selection, as shown below.

MS Graph

HTTP request types/verbs/actions that are supported in MS Graph Explorer

MS Graph Explorer supports the following HTTP actions/HTTP verbs.

MS Graph

Let’s try it out

Below, I will explain how some calls to MS Graph API can be made using the Graph Explorer.

Calls with demo tenant

The following calls can be executed using the demo tenant.

Also notice, as you type in the address bar, the Graph Explorer will show you the possible endpoints (just like intelliSense).

MS Graph

Click on the “GO” button and you will see the result in the “RESPONSE” area.

MS Graph

  • Now, type in the address bar and press “GO” button. You will see the logged in user’s organization info.MS Graph
  • The following call will return the files stored in user’s OneDrive account.MS Graph

Try some more “GET” calls on your own using the Graph Explorer. The list of more such calls can be found here.

MS Graph

Calls with your Office 365 account

The following calls will require you to login with an Office 365 account. Remember to use demo/test account and not the live account, because it may result in some live data loss.

Click on the “SIGN IN” link and login with your Office 365 test account.

Click on the “INSERT USERS TEMPLATE” link inside “REQUEST BODY” area. Once MS Graph Explorer populates some default JSON data, change it as you like and click on the “GO” button.

MS Graph

Hopefully, a new user will be created in Office 365 and Graph API will respond with HTTP Status Code 201, meaning user is created.

MS Graph

Note the id of the user which can be used in subsequent calls to edit/delete the record.

  • Let’s now try to update the user’s value e.g. surname. Let’s update the value from current “Darrow” in above screenshot to “Sharp”.
  • Copy the JSON value from the response area (i.e. values inside and including the curly brackets).
  • Remove everything else but surname field, change the surname value to “Sharp”.
  • Change the request type to “PATCH”.
  • Change the API endpoint to include the above created user
  • Click on the “GO” button.MS Graph

Graph API will process the request and update the user’s last name to “Sharp”. It will respond with the HTTP Status Code 204.

Change the request type to “GET” and fire the same call again, you will see the last name is changed to “Sharp” now.

MS Graph

  • Now, let’s fire a delete call and delete the above generated user. Use caution here not to delete any of your live users!

Change the request type to “DELETE”, keep the API endpoint same as last call and click on “GO”

MS Graph

You will see that Graph API responds with HTTP Status Code 204 again. The user is deleted from Office 365.

You can make sure the user is deleted by firing a GET on all users,

MS Graph

Check the response JSON, above user will not be in the response.

What’s next

After reading this introduction to MS Graph Explorer, I think you must be interested to know more about MS Graph API. Wait for my next article on MS Graph API, and until it is published you can go to internet and,

  • Create an Office365 developer account here.
  • Learn more about MS Graph API here.
  • Try MS Graph Explorer here.
  • Learn more about Office 365 development here.

See you in the next article, until then – Happy Learning!

Note: This article was published by me on C# Corner website here.