Getting Started With Microsoft Graph API Explorer

Microsoft Graph

Microsoft Graph provides a Single REST API endpoint to access the multiple Microsoft cloud API services such as Office 365, Exchange Online, Azure Active Directory, SharePoint etc. So there is a single authentication to access all services with the help of one REST API endpoint.

The following steps would require you to get the information from Office 365,

  1. Find the appropriate endpoint related to the cloud service using Discovery service.
  2. Identify the URL of the services your Office 365 apps want to connect to.
  3. Then get the access token from the appropriate service and make the request to the server directly.
  4. To get the information from multiple services, we have to get the multiple access tokens for each service.

But by using Microsoft Graph API, we can perform the same complex operation via a single REST API endpoint. For this we not need to discover the endpoints for each service, no need to get the access token for each service for authentication.

Graph API Queries

I have listed below some of the sample queries of Microsoft Graph API, which are used against the Microsoft cloud services.

Operation

Service endpoint

GET my profile

https://graph.microsoft.com/v1.0/me

GET my files

https://graph.microsoft.com/v1.0/me/drive/root/children

GET my photo

https://graph.microsoft.com/v1.0/me/photo/$value

GET my mail

https://graph.microsoft.com/v1.0/me/messages

GET my calendar

https://graph.microsoft.com/v1.0/me/calendar

GET my manager

https://graph.microsoft.com/v1.0/me/manager

GET last user to modify file foo.txt

https://graph.microsoft.com/v1.0/me/drive/root/children/foo.txt/lastModifiedByUser

GET unified groups I’m member of

https://graph.microsoft.com/v1.0/me/memberOf/$/microsoft.graph.group?$filter=groupTypes/any(a:a%20eq%20'unified')

GET users in my organization

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

GET group conversations

https://graph.microsoft.com/v1.0/groups/<id>/conversations

GET people related to me

https://graph.microsoft.com/beta/me/people

GET my tasks

https://graph.microsoft.com/beta/me/tasks

GET my notes

https://graph.microsoft.com/beta/me/notes/notebooks

GET files trending around me

https://graph.microsoft.com/beta/me/trendingAround

GET people I am working with

https://graph.microsoft.com/beta/me/workingWith

To view the list of common Graph API queries, refer this article.

Microsoft Graph API Explorer

Now we understand the Microsoft Graph and its queries, but how we can test the queries?

Microsoft also gives the answer via Microsoft Graph API explorer. By using this we can test any query of Graph REST API and get the results in the form json.

Follow the below steps to use the Microsoft Graph Explorer API,

  1. Navigate to Microsoft Graph API site, http://graph.microsoft.io/

    Microsoft Graph site
                                           Figure 1 Microsoft Graph site

  2. Click Graph Explorer from the top navigation.

  3. If you are not already logged in to the site, click SignIn,

    Graph Explorer
                                  Figure 2 Graph Explorer

  4. After signing in to the page, you’ll be ready to test the queries.

  5. We have two buttons on the Explorer tool. Method button and Version button.

  6. Method has below four options and that says, how the query would send to the server as a request,

    a. GET (default)
    b. POST
    c. PATCH
    d. DELETE

  7. Version button has the below two options for now and that says what tool to request based on the selected version,

    a. Beta
    b. V1.0 (default)

  8. Add the query URL in query box and press Enter to send the query request.

  9. The response result is rendered to the content box in json format and response headers rendered below the “Response Headers” heading.

  10. The response time taken for response time (Receiving request, processing the request, sending response) is also shown in the Explorer.

  11. For example, to get the groups in Office 365, use the query “https://graph.microsoft.com/v1.0/Groups“ and find the response in below screenshot,

    Graph Explorer Request & Response
                             Figure 3 Graph Explorer Request & Response

Up Next
    Ebook Download
    View all
    Learn
    View all