A First Look At The New Microsoft Graph Explorer – Part One

Note: All my blogs on Microsoft Graph API can be found here.

Recently, Microsoft has launched the new and updated version of Microsoft Graph Explorer. The concept behind the Microsoft Graph API and the Microsoft Graph Explorer remain the same, but this launch is an effort by the Microsoft Graph team to make developer experience more engaging and to add more functionality to Microsoft Graph Explorer.

I have already written an article on the previous version of Microsoft Graph Explorer here while it was in effect. But with the launch of a new version with new UI, things have changed in Microsoft Graph Explorer. So, I wanted to write an article on it which will guide you through the new version. This article is part 1 of the multipart series I plan to write on the new Microsoft Graph Explorer.

Please note that this article is written in a way that it can be read as an independent article without the need to look at my earlier article.

Remember, there is no way to access the old version of Microsoft Graph Explorer. It has been totally replaced by the current version. My first impression is that you are going to like it much more than the old version.

Before we start with what’s new in Microsoft Graph Explorer, let’s first get a quick introduction of Microsoft Graph.

Microsoft Graph

The official Microsoft documentation defines Microsoft Graph as,

“Microsoft Graph exposes multiple APIs from Office 365 and other Microsoft cloud services through a single endpoint: https://graph.microsoft.com. Microsoft Graph simplifies queries that would otherwise be more complex.”

So, in a nutshell, Microsoft 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 Microsoft Graph Explorer.

Microsoft Graph Explorer

Microsoft Graph Explorer is a fantastic tool if you want to work with Microsoft 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 first-hand experience of Microsoft Graph APIs.

Where can you access Microsoft Graph Explorer?

It can be accessed here – https://developer.microsoft.com/en-us/graph/graph-explorer

Microsoft Graph Explorer

What do you need in order to work with Microsoft Graph Explorer?

Microsoft Graph Explorer provides you default login – a sample account with which you can fire some GET calls using Microsoft Graph APIs.

But if you want to explore more and also want to fire POST, PATCH and DELETE calls to Microsoft Graph API, then you will need to login with Microsoft credentials. I will suggest you get an Office 365 developer account.

Warning

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

If you join the Microsoft 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 on it in my related article “Office 365 developer program” here.

What can you do with Microsoft Graph Explorer?

A lot!

Microsoft Graph Explorer gives you a test client to access whatever you can access with Microsoft Graph REST APIs.

Using Microsoft 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 amongst them
  • Get intelligence and insights from the Microsoft cloud (limited to commercial users only)

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

Why should you use Microsoft Graph Explorer?

Microsoft Graph Explorer is a great tool to test how Microsoft Graph APIs work. A developer can use Microsoft 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

A first look at the new Microsoft Graph Explorer

Microsoft Graph Explorer

The screen shot of the new Microsoft Graph Explorer with some annotations above is mostly self-explanatory.

Some sections are covered in more detail below. I will also cover sections on left side in black background which were not mentioned in above screen shot due to space crunch:

The “Authentication” section

Microsoft Graph Explorer

By default, it launches API calls with the in-built sample account which you can use it to get some data without login in. You can sign-in to your account using the sign in button,

Microsoft Graph Explorer

Please note one thing here. If you go to the “Request Type” drop-down, you will see,

Microsoft Graph Explorer

You are not allowed to change the request type if you are not logged in with your Microsoft account. This is because someone can fire update/delete calls to Microsoft Graph API and change the data in Microsoft sample account. So, for the sanity anything except a “GET” is disabled till your login.

Once your login with your Microsoft credentials is done, then you can fire more queries apart from “GET” request type.

There is one more use of this sample account I have found. It has bulk data for messages and other items. Your newly created Office 365 developer account may not have that much data until you do the laborious task of creating it into your account. So when you want to test paging, delta queries, etc. this sample account comes into help.

The “Sample Queries” section

Microsoft Graph Explorer

In the left side section, just below authentication you will see the “Sample Queries” section,

Microsoft Graph Explorer

Here you will find some frequently used API calls labelled under “Getting Started”.

The purpose of the sample queries section is to provide developers a ready-made API call which can be immediately executed in the Microsoft Graph Explorer without the need for the developer to go and find the API URL and input parameters in documentation.

You can directly click on any link in the “Sample Queries” section and that call will be fired immediately against the Graph API and result will be shown to you.

For example, let’s click on “my photo” link in the Sample Queries” section, you will see on the right-side section, the API call for getting user’s photo is executed and you are shown the result:

Microsoft Graph Explorer

The Graph Explorer automatically changes the API endpoint to https://graph.microsoft.com/v1.0/me/photo/$value, fires the query and shows you user’s photo.

Note the 3 different columns in the “Sample Queries” section for each row

  • Request Type
  • Brief name of API call
  • Link to documentation

Microsoft Graph Explorer

The first column
indicates the type of API call, which is “GET” here.

The second column indicates a brief name for the API call.

e.g. if you move the cursor over the “my profile” text you will see the tooltip,

Microsoft Graph Explorer

The tooltip/hint here indicates the actual API endpoint “https://graph.microsoft.com/v1.0/me“ which will be used in the call and which will be seen later in the API address bar once the call is fired,

Microsoft Graph Explorer

The third column is the link to the relevant Graph API documentation section. If you move mouse over to it, you will see tooltip for documentation,

Microsoft Graph Explorer

If you click on that link, the documentation will load in the new tab,

Microsoft Graph Explorer

Do you want to see some more sample queries?

Click on the “show more samples” link at the bottom of “Sample Queries” section,

Microsoft Graph Explorer

Microsoft Graph Explorer

A “Sample Categories” popup will open with some category/group names and options for each to make the selection ON or OFF,

Microsoft Graph Explorer

Notice that you were already seeing the “Getting Started” section, and here the section’s selection is “On”,

Microsoft Graph Explorer

The (6) at the end of “Getting Started” indicates there are 6 queries/endpoints in this section. This can be verified if you close the pop-up and once again go back to “Sample Queries” section,

Microsoft Graph Explorer

Now back to the “Sample Categories” popup. Let’s now select some more categories and see what happens. I have selected three more categories – Users, Outlook mail and OneDrive,

Microsoft Graph Explorer

Click on the “X” button on top right section to close the pop-up. See the “Sample Categories” section, you will have the selected categories in it,

Microsoft Graph Explorer

You can click on any call to get it fired and see result in Microsoft Graph Explorer.

Notice one thing here that if you are not yet logged in and using the sample account, then you cannot fire the “POST” calls,

Microsoft Graph Explorer

Once again click the “show more samples” link, and make all categories selection “off” and close the pop-up,

Microsoft Graph Explorer

You will see now there are no more  sample queries,

Microsoft Graph Explorer

This flow is just to show you how you can make category selection “on” or “off”. I will suggest you to check all the categories and all its queries once at least.

That’s it for part 1. I will cover more in part 2 of this series.

See you in the next article. Until then – Happy Learning!

Note: This article was first published by me on C# Corner website on May 09 2017 here.

Header image courtesy: Microsoft

Introduction To MS Graph Explorer

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

Note: Microsoft has launched a new version of MS Graph Explorer some time after this article was published. For newer version of my article on the new MS Graph Explorer, please visit here.

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, https://graph.microsoft.com. 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.

Warning

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:

 https://graph.microsoft.com/v1.0/organization/users

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 https://graph.microsoft.com/v1.0/organization 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.

Image courtesy: Microsoft