A First Look At The New Microsoft Graph Explorer - Part Two

Part one of the series,  “A first look at the new Microsoft Graph Explorer” can be accessed here. If you have not read it yet, I suggest you read it first to maintain continuity of your reading.

I will continue from where I left off in the last article. We will see the remaining sections of the Microsoft Graph Explorer in some detail.

The objective of this article is to cover the following topics, among others:

  • History section
  • Request & Response sections
  • Share Query section

For a quick note; you can see Microsoft Graph Explorer here.

The “History” section

Office Development

Scroll down on the left section to see the History section.

You can collapse “Sample Queries” section if it has some sample queries in it, to see the History section quickly.

Office Development

If the “History” section is already collapsed, expand it.

Office Development

Upon expanding, or if it is already expanded, you will see it like below.

Office Development

If you haven't executed any Graph API at all, then the section will be empty.

Office Development

The “History” section maintains the history of the Graph API calls you executed and by clicking on the links in this section, you can easily re-play those calls. A fresh request will be made to the Graph API when you click on a link from history.

Note that the “History” section maintains only the history of the request, and not the response. This means, the request will be fired again and you will always see the latest response from Graph API. There is no way to see what the response was originally when you fired that query  the first time.

As you make the Graph API calls, the browser URL does not change, so to get back to any of your previous calls, you can use this “History” section.

Let’s see now what’s there for each row in the “History” section.

Office Development

  • “GET” and “PATCH” indicates the request type
  • The “/v1.0/me/” indicates the API endpoint. It is equivalent of the full endpoint https://graph.microsoft.com/v1.0/me/, but for brevity it is displayed like this.
  • “200”, “204”, “400” are the HTTP response codes of the API call indicating what happened at that time
  • “3 minutes ago” displays the time at which that call was made
  • “146 ms” is the time taken by the Graph Explorer to execute the request.

The “History” section data is stored in cookies in your local machine and it is browser specific.

If you were working on Internet Explorer and if you open Firefox or vice versa, then you will not see the same history. This is true even if you are logged in using your Microsoft account.

Do you want to see more history? Click on the “show more” link at the bottom right of the history section.

Office Development

Office Development

Once you click on the “show more” link, Graph Explorer will open “History” popup.

Office Development

The contents of the popup are self-explanatory. You can either remove individual entry by taking the mouse over to a row and clicking “x” button at the end of the row, or remove all entries by clicking “Remove All” button.

If you click on any row, then the popup will close and the API call will be fired again.

“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.

It is possible to pass additional data to MS Graph API thru the “Request Headers” and “Request Body” sections which can be found just below the API address bar,

Office Development

“Request Header” section

The HTTP request headers can be specified in the “Request Headers” area in form of key-value pairs. If you see by default there will be one textbox for the “Key” entry, on value side there is no textbox,

Office Development

The textbox on the “Value” side will appear once you start typing something in the “Key” textbox.

Let’s write “Accept” in the “Key” textbox,

Office Development

Immediately you will see there will be a textbox beneath the “Value” header, and a new row for “Key” textbox will be added as well.

Note that you must “type” something in the “Key” textbox for the “Value” textbox to be visible. If you copy and paste something inside the textbox, then the “Value” textbox will not appear.

How to pass some value in request header, how to execute the call and how to interpret the result will be covered later.

“Request Body” section

Let’s now see the “Request Body” section.

Click on the “Request Body” link just besides “Request Header” link.

Office Development

You will see a text area in which you can enter free-form text,

Office Development

“GET” requests will not have a request body, but to show you a demo I have copied one JSON result body and pasted it in the request body text area,

Office Development

You see it has little bit of “intellisense” too! It identifies the matching starting “{“ bracket when your cursor moves to the ending “}” bracket.

You can fire any “GET” call with anything in the request body, Graph API will just ignore it,

Office Development

How to pass some value in request body, how to execute the call, and how to interpret the result will be covered later.

“Response” sections

The response section is just below the requests section and it shows you the response you get back from the Microsoft Graph API call.

There are three sections here: “Response Message”, “Response Preview” and “Response Headers”,

Office Development

“Response Message” section is visible only after you fire an API call.

“Response Preview” and “Response Headers” both are read-only text areas because you are not supposed to write anything inside it.

For the demo, just click on “my profile” link in the “Getting Started” section inside “Sample Queries” on left side,

Office Development

Immediately you will see the API call result in the results section,

Office Development

“Response Message” section

The “Response Message” section is highlighted above.

It indicates,

Office Development

  • Success: the API call executed without any errors
  • Status Code 200: HTTP response code
    • For the understanding of HTTP status codes, click here.
  • 139ms: request execution time taken by Graph Explorer

In case of some failure, it will be like,

Office Development

“Response Preview” section

Office Development

It shows the Graph API call’s result body in JSON format.

“Response Headers” section

Click on the “Response Headers” section to see the HTTP response headers values,

Office Development

You will see here values for content-Type, request-id, duration, etc. among others. The response header values prove very handy sometimes in debugging API call errors.

Which API versions are supported in Microsoft Graph Explorer?

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

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

Office Development

When to change the version and how to execute the API calls is covered later.

Which HTTP request types/verbs/actions are supported in Microsoft Graph Explorer?

Microsoft Graph Explorer supports the following HTTP actions/HTTP verbs as shown below. Remember you must be logged in for the dropdown to be enabled,

Office Development

“PUT” has been added now which did not exist in earlier version of MS Graph Explorer.

When to change the request type and how to execute the API calls is covered later.

“Run Query” button

Office Development

This one is obvious, but I thought my article would not be complete without mentioning each part of the MS Graph Explorer!

You press it to execute the call to the Graph API. If the API endpoint is not specified or some garbage value is entered, then it will simply ignore and will not execute anything. Cool!

“Share Query” link

Office Development

It’s the little link on the right side on top of response text area.

Office Development

Using this link, you can share your queries with others. It will allow others to execute the same query as you did in the MS Graph Explorer.

For the demo, click on the “my mail” link on left side,

Office Development

The API endpoint will be changed to https://graph.microsoft.com/v1.0/me/messages and the result will be shown to you.

Now click on the “Share Query” link,

Office Development

You will see the following pop-up,

Office Development

The textbox has following link inside it:

https://developer.microsoft.com/en-us/graph/graph-explorer?request=me/messages&method=GET&version=v1.0

It is formatted such that the link can be fired from any browser and the API call will be setup.

To test it, copy the link and click on “Close” to close the dialog.

Open another browser and paste the link in its address bar and press Enter,

Office Development

You will see that the API endpoint, HTTP request type and API version are set. You must press the “Run Query” button to execute the call.

What’s next

I will cover execution of some queries with sample account and Office 365 developer account in the next article.

Moreover, after reading this introduction to Microsoft Graph Explorer, I think you might be interested to know more about Microsoft Graph API.

Wait for my next article in this series, until it is published you can:

  • Read my article on Office365 developer program here.
  • Create an Office365 developer account here.
  • Learn more about Microsoft Graph API here.
  • Try Microsoft Graph Explorer here.
  • Learn more about Office 365 development here.

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

Up Next
    Ebook Download
    View all
    Learn
    View all