{"id":5713,"date":"2020-12-22T09:00:49","date_gmt":"2020-12-22T17:00:49","guid":{"rendered":"https:\/\/officedevblogs.wpengine.com\/?p=5713"},"modified":"2021-11-17T12:46:46","modified_gmt":"2021-11-17T20:46:46","slug":"msgraphmailbag-use-graph-explorer-like-a-professional","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/msgraphmailbag-use-graph-explorer-like-a-professional\/","title":{"rendered":"Microsoft Graph Mailbag &#8211; Use Graph Explorer Like a Professional"},"content":{"rendered":"<p>In today&#8217;s Microsoft Graph Mailbag post we will cover features of Graph Explorer to help you be as effective as possible when querying Microsoft Graph.\u00a0 For those unfamiliar, <a href=\"https:\/\/aka.ms\/ge\">Graph Explorer<\/a> is a tool that lets you make requests and see responses against Microsoft Graph.\u00a0 The latest release has added many improvements to help you develop queries and explore requests and responses.\u00a0 Additionally, you can also see ways to leverage your queries in our <a href=\"https:\/\/docs.microsoft.com\/graph\/sdks\/sdks-overview\">Microsoft Graph SDKs<\/a>, <a href=\"https:\/\/adaptivecards.io\/\">adaptive cards<\/a>, or <a href=\"https:\/\/github.com\/microsoftgraph\/microsoft-graph-toolkit\">Microsoft Graph Toolkit<\/a> components.<\/p>\n<p>Please be sure to follow this blog series using\u00a0<a href=\"https:\/\/aka.ms\/MSGraphMailbag\">https:\/\/aka.ms\/MSGraphMailbag<\/a>\u00a0or with RSS using\u00a0<a href=\"https:\/\/developer.microsoft.com\/en-us\/graph\/blogs\/feed\/?tag=MSGraphMailbag\">https:\/\/developer.microsoft.com\/en-us\/graph\/blogs\/feed\/?tag=MSGraphMailbag<\/a>.<\/p>\n<h2>Whatif query parameter<\/h2>\n<p>Microsoft Graph is an API gateway that calls underlying APIs when running a query.\u00a0 In general, you do not need to be concerned about the underlying API that is called, but at times it can be helpful for troubleshooting or understanding how your query is processed.<\/p>\n<p>Recently a partner shared the following 2 queries:<\/p>\n<ul>\n<li>\u201c<a href=\"https:\/\/developer.microsoft.com\/graph\/graph-explorer?request=users%2Fme%2FjoinedTeams&amp;method=GET&amp;version=v1.0&amp;GraphUrl=https:\/\/graph.microsoft.com\">\/users\/me\/joinedTeams<\/a>\u201d returned a successful result<\/li>\n<li>\u201c<a href=\"https:\/\/developer.microsoft.com\/graph\/graph-explorer?request=users%2Fme&amp;method=GET&amp;version=v1.0&amp;GraphUrl=https:\/\/graph.microsoft.com\">\/users\/me<\/a>\u201d returned an error<\/li>\n<\/ul>\n<p>By adding the \u201c$whatif\u201d query parameter you can see that the first query is routed through the underlying Teams APIs while the second query is routed through Azure AD (Directory Services).\u00a0 As it turns out \u201c\/users\/me\u201d is an invalid query (\u201c\/me\u201d is the appropriate request) and hence fails.\u00a0 On the other hand \u201c\/users\/me\/joinedTeams\u201d is valid because the initial lookup for the user on the Teams endpoint does resolve.\u00a0 This isn\u2019t readily apparent when first looking at the syntax but a quick check with $whatif helps see how the seemingly similar requests are processed differently.<\/p>\n<h2>Share a link to Graph Explorer query<\/h2>\n<p>After you run a query in Graph Explorer it is possible to share a link to the query, including any request body and headers.\u00a0 In the lower half response section of Graph Explorer click the Share button, then copy the link that is generated.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-5727 \" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image7-1-1024x258.jpg\" alt=\"\" width=\"928\" height=\"234\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image7-1-1024x258.jpg 1024w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image7-1-300x76.jpg 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image7-1-768x194.jpg 768w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image7-1.jpg 1532w\" sizes=\"(max-width: 928px) 100vw, 928px\" \/><\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-5725\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image8.jpg\" alt=\"\" width=\"343\" height=\"271\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image8.jpg 521w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image8-300x237.jpg 300w\" sizes=\"(max-width: 343px) 100vw, 343px\" \/><\/p>\n<p>Try out <a href=\"https:\/\/developer.microsoft.com\/graph\/graph-explorer?request=me&amp;method=GET&amp;version=v1.0&amp;GraphUrl=https:\/\/graph.microsoft.com&amp;requestBody=eyJwcm9wZXJ0eTEiOiJzYW1wbGUgd29yZHMifQ==&amp;headers=W3sibmFtZSI6IkNvbnRlbnQtVHlwZSIsInZhbHVlIjoiYXBwbGljYXRpb24vanNvbiJ9XQ==\">this link<\/a> for an example of a request that contains a request body and headers.<\/p>\n<h2>Access tokens<\/h2>\n<p>When you log into Graph Explorer, Graph Explorer will request an access token on your behalf which will then be used for any queries sent to Microsoft Graph.\u00a0 Click the Access token button below the request URI box to show this access token.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-5719\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image5-1024x322.jpg\" alt=\"\" width=\"935\" height=\"294\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image5-1024x322.jpg 1024w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image5-300x94.jpg 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image5-768x241.jpg 768w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image5-1536x483.jpg 1536w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image5.jpg 1547w\" sizes=\"(max-width: 935px) 100vw, 935px\" \/><\/p>\n<p>A recently added feature (<a href=\"https:\/\/github.com\/microsoftgraph\/microsoft-graph-explorer-v4\/pull\/754\">PR 754<\/a>) from <a href=\"https:\/\/twitter.com\/sebastienlevert\">S\u00e9bastien Levert<\/a> (newest Microsoft Graph CPx team member) allows you to click the \u201c{}\u201d button to open this access token in the <a href=\"https:\/\/jwt.ms\">https:\/\/jwt.ms<\/a> tool (provided by the Microsoft Identity team.)\u00a0 Note that decoding access tokens with this tool is only supported for <span style=\"text-decoration: underline\">work and school accounts<\/span> (not consumer Microsoft accounts, also called MSAs).\u00a0 This is due to MSAs using a compact format for the access token.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-5720\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image6.jpg\" alt=\"\" width=\"306\" height=\"174\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image6.jpg 374w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image6-300x171.jpg 300w\" sizes=\"(max-width: 306px) 100vw, 306px\" \/><\/p>\n<p>The following screenshot shows a subset of claims decoded from the access token when using <a href=\"https:\/\/jwt.ms\">https:\/\/jwt.ms<\/a>.\u00a0 Read more about <a href=\"https:\/\/docs.microsoft.com\/graph\/auth\/auth-concepts\">Authentication and authorization basics for Microsoft Graph<\/a> in our documentation.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-5728\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image9.jpg\" alt=\"\" width=\"577\" height=\"129\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image9.jpg 975w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image9-300x67.jpg 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image9-768x172.jpg 768w\" sizes=\"(max-width: 577px) 100vw, 577px\" \/><\/p>\n<h2>Microsoft 365 Developer Program<\/h2>\n<p>When you first navigate to Graph Explorer you query a demo tenant.\u00a0 You can log into one of your own tenants but if you would like a sandbox tenant you can sign up for the <a href=\"https:\/\/aka.ms\/m365devprogram\">Microsoft 365 Developer Program<\/a>.\u00a0 One of the benefits is a free, renewable 90-day Microsoft\u00a0365 E5 developer subscription that includes 25 users.<\/p>\n<p>Click the gear icon in the upper left authentication box then select \u201cGet a sandbox with sample data\u201d.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-5729\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image10.jpg\" alt=\"\" width=\"502\" height=\"256\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image10.jpg 788w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image10-300x153.jpg 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image10-768x392.jpg 768w\" sizes=\"(max-width: 502px) 100vw, 502px\" \/><\/p>\n<h2>Permissions<\/h2>\n<p>If you do not have permissions required to run a given query you get the below error message (HTTP 403 Forbidden).<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-5716\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image2.jpg\" alt=\"\" width=\"715\" height=\"40\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image2.jpg 840w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image2-300x17.jpg 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image2-768x43.jpg 768w\" sizes=\"(max-width: 715px) 100vw, 715px\" \/><\/p>\n<p>You can view and consent to a required permission(s) by clicking the \u201cModify permissions\u201d tab under the request URL.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-5717\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image3-1024x249.jpg\" alt=\"\" width=\"868\" height=\"211\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image3-1024x249.jpg 1024w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image3-300x73.jpg 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image3-768x186.jpg 768w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image3-1536x373.jpg 1536w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image3.jpg 1743w\" sizes=\"(max-width: 868px) 100vw, 868px\" \/><\/p>\n<p>Separately, if you are logged in to Graph Explorer you can click the gear icon in the upper left authentication box then select \u201cSelect permissions\u201d.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-5715\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image1.jpg\" alt=\"\" width=\"566\" height=\"268\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image1.jpg 860w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image1-300x142.jpg 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image1-768x363.jpg 768w\" sizes=\"(max-width: 566px) 100vw, 566px\" \/><\/p>\n<p>On the flyout menu to the right you can select and consent individual permissions.\u00a0 Use the search box to filter for specific permissions, select them, and then click the Consent button at bottom.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-5718\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image4.jpg\" alt=\"\" width=\"392\" height=\"364\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image4.jpg 969w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image4-300x279.jpg 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/12\/2020-12-22-Image4-768x713.jpg 768w\" sizes=\"(max-width: 392px) 100vw, 392px\" \/><\/p>\n<h2>Conclusion<\/h2>\n<p>In today\u2019s post we looked at ways to use many of the new features in Graph Explorer for access tokens, sharing queries, permissions, sandbox tenants, and more.\u00a0 If you have any feedback or suggested features for Graph Explorer please open an issue on the GitHub repo <a href=\"https:\/\/github.com\/microsoftgraph\/microsoft-graph-explorer-v4\">microsoftgraph\/microsoft-graph-explorer-v4<\/a>.<\/p>\n<p>Today\u2019s post was written by Brian T. Jackett, Sr. Customer and Partner Experience (CPx) PM with the Microsoft Graph Team.\u00a0 You can follow Brian on his <a href=\"https:\/\/briantjackett.com\/\">blog<\/a> or on Twitter <a href=\"https:\/\/twitter.com\/briantjackett\">@BrianTJackett<\/a>.\u00a0 Join us for our next post Jan 12, 2021.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In today&#8217;s Microsoft Graph Mailbag post we will cover features of Graph Explorer to help you be as effective as possible when querying Microsoft Graph.<\/p>\n","protected":false},"author":69075,"featured_media":25159,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[3],"tags":[15,17],"class_list":["post-5713","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-microsoft-graph","tag-graph-explorer","tag-msgraphmailbag"],"acf":[],"blog_post_summary":"<p>In today&#8217;s Microsoft Graph Mailbag post we will cover features of Graph Explorer to help you be as effective as possible when querying Microsoft Graph.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/5713","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/users\/69075"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/comments?post=5713"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/5713\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media\/25159"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media?parent=5713"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/categories?post=5713"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/tags?post=5713"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}