{"id":6478,"date":"2021-06-23T10:19:06","date_gmt":"2021-06-23T18:19:06","guid":{"rendered":"https:\/\/officedevblogs.wpengine.com\/?p=6478"},"modified":"2022-05-26T14:38:51","modified_gmt":"2022-05-26T21:38:51","slug":"explore-microsoft-graph-with-postman","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/explore-microsoft-graph-with-postman\/","title":{"rendered":"Microsoft Graph Mailbag &#8211; Explore Microsoft Graph with Postman"},"content":{"rendered":"<p>In today\u2019s Microsoft Graph Mailbag post, we\u2019ll take a look at the <a href=\"https:\/\/aka.ms\/graphpostmanwkspc\" target=\"_blank\" rel=\"noopener noreferrer\">Microsoft Graph Postman collection<\/a>.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-6485\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2021\/06\/Image0-1024x524.jpg\" alt=\"Microsoft Graph + Postman\" width=\"400\" height=\"205\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2021\/06\/Image0-1024x524.jpg 1024w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2021\/06\/Image0-300x154.jpg 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2021\/06\/Image0-768x393.jpg 768w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2021\/06\/Image0.jpg 1488w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/p>\n<p>Please be sure to follow this blog series using\u202f<a href=\"https:\/\/aka.ms\/MSGraphMailbag\">https:\/\/aka.ms\/MSGraphMailbag<\/a>\u202for with RSS using\u202f<a href=\"https:\/\/developer.microsoft.com\/graph\/blogs\/feed\/?tag=MSGraphMailbag\">https:\/\/developer.microsoft.com\/graph\/blogs\/feed\/?tag=MSGraphMailbag<\/a>.<\/p>\n<h2>Introduction<\/h2>\n<p>The Microsoft Graph Postman collection is a curated set of API requests that you can use to experiment with and explore the Microsoft Graph API. It serves a similar purpose as the <a href=\"https:\/\/developer.microsoft.com\/graph\/graph-explorer\">Graph Explorer<\/a>, with a few notable differences. With the Postman collection, you can save custom requests and make requests with an <a href=\"https:\/\/docs.microsoft.com\/graph\/auth-v2-service\">app-only token<\/a>.<\/p>\n<h2>Getting started<\/h2>\n<p>Instructions on forking and configuring the collection are found in <a href=\"https:\/\/docs.microsoft.com\/graph\/use-postman\">Use Postman with the Microsoft Graph API<\/a>. Jeremy Thake has posted a short <a href=\"https:\/\/www.youtube.com\/watch?v=3RTHY3jScmA\" target=\"_blank\" rel=\"noopener noreferrer\">YouTube video<\/a> on getting started. I\u2019ll summarize the process here.<\/p>\n<h3>Fork the collection<\/h3>\n<p><a href=\"https:\/\/learning.postman.com\/docs\/collaborating-in-postman\/version-control-for-collections\/#forking-a-collection\">Forking the collection<\/a> is necessary to get your own copy of the collection that you can modify. Once you&#8217;ve forked the collection into your personal workspace, you can use it in your browser or using the Postman desktop application.<\/p>\n<h3>Configure authentication<\/h3>\n<p>Postman has support for OAuth2 built in. The requests in our collection have been pre-configured to use the appropriate OAuth2 flows. Requests in the\u00a0<strong>Delegated\u00a0<\/strong>folder use the authentication code flow to authenticate as a user. Requests in the\u00a0<strong>Application<\/strong> folder use the client credentials flow to authenticate as an application. Keep in mind that in order to use the requests in the <strong>Application <\/strong>folder, you will need an administrator to consent to the application permissions.<\/p>\n<p>As you explore the requests in the collection, you&#8217;ll need to add additional permissions to your application registration and request a new token. For example, if you followed along with the instructions in our documentation, your application registration currently has <code>User.Read<\/code> and <code>Mail.Read<\/code> delegated permissions, and <code>User.Read.All<\/code> application permissions. That means the\u00a0<strong>Get my messages\u00a0<\/strong>request will succeed, but the\u00a0<strong>Get my calendars<\/strong> request will fail with <code>403 Forbidden<\/code>. To complete the request successfully, add <code>Calendars.Read<\/code> to the\u00a0<strong>API permissions\u00a0<\/strong>on the application registration, grant admin consent, and <a href=\"https:\/\/docs.microsoft.com\/graph\/use-postman#step-5---get-a-delegated-access-token\">get a new token<\/a> in Postman.<\/p>\n<h3>Add a request<\/h3>\n<p>Once you&#8217;ve explored the requests included in the collection, you may want to add additional requests. For example, there are no request for the personal contacts APIs. Let&#8217;s walk through the process of adding a request to list the authenticated user&#8217;s contacts.<\/p>\n<p>First, add a\u00a0<strong>Personal contacts\u00a0<\/strong>folder in the\u00a0<strong>Delegated\u00a0<\/strong>folder. Select the ellipsis (\u2026) on the\u00a0<strong>Delegated\u00a0<\/strong>folder to open the action menu, and select\u00a0<strong>Add Folder<\/strong>. Be sure to leave the\u00a0<strong>Type\u00a0<\/strong>field set to\u00a0<strong>Inherit auth from parent<\/strong>.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-6480\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2021\/06\/CreateFolder-1024x630.png\" alt=\"A screenshot of the Create Folder menu item in a Postman collection\" width=\"800\" height=\"492\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2021\/06\/CreateFolder-1024x630.png 1024w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2021\/06\/CreateFolder-300x185.png 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2021\/06\/CreateFolder-768x473.png 768w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2021\/06\/CreateFolder.png 1076w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>Add a request to the\u00a0<strong>Personal contacts\u00a0<\/strong>folder named\u00a0<strong>Get my contacts<\/strong>. Using the information from the <a href=\"https:\/\/docs.microsoft.com\/graph\/api\/user-list-contacts?view=graph-rest-1.0\">list contacts API reference page<\/a>, we can fill in the request.<\/p>\n<ul>\n<li>The HTTP method is GET, so leave the method dropdown set to\u00a0<strong>GET<\/strong>.<\/li>\n<li>The relative API url is <code>\/me\/contacts<\/code>, so the full request URL is <code>https:\/\/graph.microsoft.com\/v1.0\/me\/contacts<\/code>.<\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-6481 size-full\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2021\/06\/GetContacts.png\" alt=\"A screenshot of the Postman request method and URL\" width=\"458\" height=\"116\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2021\/06\/GetContacts.png 458w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2021\/06\/GetContacts-300x76.png 300w\" sizes=\"(max-width: 458px) 100vw, 458px\" \/><\/p>\n<p>Finally, update your application registration to add the required permissions for the API. According to the API reference page, the least-privileged permission requires is <code>Contacts.Read<\/code>. Add the permission to your application registration&#8217;s delegated permissions. Once completed be sure to get a new access token by selecting the\u00a0<strong>Delegated\u00a0<\/strong>folder then selecting the\u00a0<strong>Get New Access Token\u00a0<\/strong>button on the\u00a0<strong>Authorization<\/strong> tab. Select the\u00a0<strong>Use Token\u00a0<\/strong>button to select the new token.<\/p>\n<p><img decoding=\"async\" class=\"size-full wp-image-6482 aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2021\/06\/UseToken.png\" alt=\"A screenshot of the Postman Manage Access Tokens dialog\" width=\"792\" height=\"452\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2021\/06\/UseToken.png 792w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2021\/06\/UseToken-300x171.png 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2021\/06\/UseToken-768x438.png 768w\" sizes=\"(max-width: 792px) 100vw, 792px\" \/><\/p>\n<p>You can now return to your\u00a0<strong>Get my contacts\u00a0<\/strong>request and select\u00a0<strong>Send<\/strong>. The response lists the user&#8217;s contacts. Select\u00a0<strong>Save\u00a0<\/strong>to save the request to your fork of the collection.<\/p>\n<h2>Contribute to the collection<\/h2>\n<p>The number of available APIs on Microsoft Graph is way more than the currently included requests, and new APIs are added frequently. To be frank &#8211; we need help covering all of the available APIs! If you&#8217;ve created new requests that you&#8217;d like to share with the rest of the Microsoft Graph developer community, we strongly urge you to <a href=\"https:\/\/learning.postman.com\/docs\/collaborating-in-postman\/version-control-for-collections\/#creating-pull-requests\">submit a pull request<\/a>. You can also keep your forked copy up-to-date by <a href=\"https:\/\/learning.postman.com\/docs\/collaborating-in-postman\/version-control-for-collections\/#pulling-updates\">pulling updates<\/a>.<\/p>\n<h2>Conclusion<\/h2>\n<p>In this post, we learned how to fork the Microsoft Graph Postman collection and how to add new requests. With this you can experiment with the API and share your requests with the rest of the community. Until next time!<\/p>\n<p>Today\u2019s post was written by Jason Johnston, Principal Content Developer at Microsoft.\u202fYou can follow Jason on Twitter <a href=\"https:\/\/twitter.com\/JasonJohMSFT\">@JasonJohMSFT<\/a>.\u202fJoin us for our next post July 13, 2021.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to use the Microsoft Graph Postman collection to explore the Microsoft Graph API.<\/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":[17],"class_list":["post-6478","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-microsoft-graph","tag-msgraphmailbag"],"acf":[],"blog_post_summary":"<p>Learn how to use the Microsoft Graph Postman collection to explore the Microsoft Graph API.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/6478","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=6478"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/6478\/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=6478"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/categories?post=6478"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/tags?post=6478"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}