{"id":2199,"date":"2018-11-26T11:00:23","date_gmt":"2018-11-26T11:00:23","guid":{"rendered":"https:\/\/developer.microsoft.com\/en-us\/office\/blogs\/?p=2199"},"modified":"2018-11-26T11:00:23","modified_gmt":"2018-11-26T11:00:23","slug":"30daysmsgraph-day-26-use-case-calling-microsoft-graph-using-flow","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/30daysmsgraph-day-26-use-case-calling-microsoft-graph-using-flow\/","title":{"rendered":"30DaysMSGraph \u2013 Day 26 \u2013 Use case: Calling Microsoft Graph using Flow"},"content":{"rendered":"<p><a href=\"https:\/\/aka.ms\/30DaysMSGraph\">List of all posts in the #30DaysMSGraph series<\/a><\/p>\n<p>-Today\u2019s post written by <a href=\"https:\/\/twitter.com\/Boejstrup\">Martin Boejstrup<\/a><\/p>\n<p>In <a href=\"https:\/\/developer.microsoft.com\/en-us\/graph\/blogs\/30daysmsgraph-day-25-use-case-create-a-onenote-notebook\">Day 25<\/a> we learned how to update OneNote using Microsoft Graph. In todays post we will show you how to make Microsoft Graph API calls using Microsoft Flow.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-2219\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/30DaysMSGraph_Day26_Source.jpg\" alt=\"\" width=\"1280\" height=\"853\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/30DaysMSGraph_Day26_Source.jpg 1280w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/30DaysMSGraph_Day26_Source-300x200.jpg 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/30DaysMSGraph_Day26_Source-1024x682.jpg 1024w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/30DaysMSGraph_Day26_Source-768x512.jpg 768w\" sizes=\"(max-width: 1280px) 100vw, 1280px\" \/><\/p>\n<p>For those of you who are not familiar with Microsoft Flow, do not worry. Microsoft Flow is easy to get started with; <a href=\"https:\/\/docs.microsoft.com\/en-us\/flow\/getting-started\">Get started with Microsoft Flow<\/a>. If you do not what to make the Flow from scratch, you can import the flow packed in your environment; <a href=\"https:\/\/flow.microsoft.com\/es-es\/blog\/import-export-bap-packages\/\">Import your flows across environments<\/a>. Download the Flow Package <a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/MicrosoftGraphandFlow30DaysMSGraph.zip\">here<\/a>.<\/p>\n<p>To use Microsoft Flow, you also need assign a Flow License. They are included in all Office 365 license types.<\/p>\n<h3>Azure AD App registration<\/h3>\n<p>As mentioned in <a href=\"https:\/\/developer.microsoft.com\/en-us\/graph\/blogs\/30daysmsgraph-day-9-azure-ad-applications-on-v2-endpoint\">Day 9<\/a> and <a href=\"https:\/\/developer.microsoft.com\/en-us\/graph\/blogs\/30daysmsgraph-day-10-azure-ad-applications-on-v1-endpoint\">Day 10<\/a> we covered the process for registering Azure AD Apps. Either of the app registrations should work with the instructions in this article.\u00a0 To use Microsoft Graph in Microsoft Flow you need to register an Application ID and a Secret key.<\/p>\n<p>You also need your tenant name ex. Contoso.onmicrosoft.com<\/p>\n<h3>Create a Flow to get all users using Microsoft Graph<\/h3>\n<p>Open <a href=\"https:\/\/flow.microsoft.com\/\">https:\/\/flow.microsoft.com<\/a> , click My flows and click New-Create from blank<\/p>\n<p>Add Flow button as trigger<\/p>\n<p><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day26-Image-1.png\" alt=\"\" width=\"613\" height=\"229\" \/><\/p>\n<p>Add a step (action) &#8211; Initialize variable\n<img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day26-Image-2.png\" alt=\"\" width=\"608\" height=\"674\" \/><\/p>\n<p>Add a name, change the type to String and add the value of the Graph URL.<\/p>\n<p>In this example the Graph URL (https:\/\/graph.microsoft.com\/v1.0\/users?$filter=Department eq &#8216;IT&#8217;) is getting all users and filter where Department is IT.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day26-Image-3.png\" alt=\"\" width=\"602\" height=\"166\" \/><\/p>\n<p>Read more about filter option in <a href=\"https:\/\/developer.microsoft.com\/en-us\/graph\/blogs\/30daysmsgraph-day-5-query-parameters-part-1\">Day 5 \u2013 Query Parameters Part 1<\/a> post.<\/p>\n<p>Add a step (action) \u2013 HTTP-HTTP<\/p>\n<p><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day26-Image-4.png\" alt=\"\" width=\"611\" height=\"670\" \/><\/p>\n<p>Change method to GET, Add the GraphUrl variable, and click Show advanced options<\/p>\n<p><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day26-Image-5.png\" alt=\"\" width=\"1020\" height=\"332\" \/><\/p>\n<p>Set Authentication to Active Directory OAuth, enter your tenant name, set Audience to <a href=\"https:\/\/graph.microsoft.com\/\">https:\/\/graph.microsoft.com<\/a>, enter ApplicationID, Client ID (you created in Day 9 or Day 10)<\/p>\n<p>, Set Credential Type to Secret and the Secret key (you created in Day 9 or Day 10)<\/p>\n<p><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day26-Image-6.png\" alt=\"\" width=\"600\" height=\"559\" \/><\/p>\n<p>Give the Flow a name, click Save and Test the flow.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day26-Image-7.png\" alt=\"\" width=\"927\" height=\"355\" \/><\/p>\n<p>Chose I\u2019ll perform the trigger action and Test<\/p>\n<p><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day26-Image-8.png\" alt=\"\" width=\"331\" height=\"207\" \/><\/p>\n<p>Click the &#8220;Run flow&#8221; button.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-2217\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day26-RunFlow-1.png\" alt=\"\" width=\"676\" height=\"257\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day26-RunFlow-1.png 1425w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day26-RunFlow-1-300x114.png 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day26-RunFlow-1-1024x389.png 1024w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day26-RunFlow-1-768x292.png 768w\" sizes=\"(max-width: 676px) 100vw, 676px\" \/><\/p>\n<p>Click &#8220;Done&#8221; button after the Flow execution is complete.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-2218\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day26-RunFlow-2.png\" alt=\"\" width=\"758\" height=\"338\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day26-RunFlow-2.png 1422w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day26-RunFlow-2-300x134.png 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day26-RunFlow-2-1024x457.png 1024w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day26-RunFlow-2-768x342.png 768w\" sizes=\"(max-width: 758px) 100vw, 758px\" \/><\/p>\n<p>Check the Run history<\/p>\n<p><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day26-Image-9.png\" alt=\"\" width=\"930\" height=\"404\" \/><\/p>\n<p>Click on the HTTP action to view the result in the request body:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day26-Image-10.png\" alt=\"\" width=\"605\" height=\"871\" \/><\/p>\n<p>Now we you have the result as JSON format.<\/p>\n<p>Edit the flow again and add the Create HTML table action<\/p>\n<p><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day26-Image-11.png\" alt=\"\" width=\"604\" height=\"551\" \/><\/p>\n<p>Add the Expression body(&#8216;HTTP&#8217;)[&#8216;value&#8217;] in From, and Include headers<\/p>\n<p><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day26-Image-12.png\" alt=\"\" width=\"1030\" height=\"333\" \/><\/p>\n<p>Click Save and Test the flow.<\/p>\n<p>Click on the Create HTML Table action to view the result in the request body<\/p>\n<p><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day26-Image-13.png\" alt=\"\" width=\"609\" height=\"683\" \/><\/p>\n<p>You have now made a sample on how to use Microsoft Graph using Flow. Add more actions to archive your needs.<\/p>\n<h2>Try It Out<\/h2>\n<p>Create your own Microsoft Flow using Microsoft Graph. Then do one of the following:<\/p>\n<ol>\n<li>Create Azure AD app registration (refer to Day 9 or Day 10 posts for more information)<\/li>\n<li>Create the Flow using the above sample or download the flow package and update that.<\/li>\n<\/ol>\n<p>Join us tomorrow as we will show you how to use Microsoft Graph to talk to Teams in <a href=\"https:\/\/developer.microsoft.com\/en-us\/graph\/blogs\/30daysmsgraph-day-27-use-case-create-a-team\">Day 27<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In todays post we will show you how to make Microsoft Graph API calls using Microsoft Flow.<\/p>\n","protected":false},"author":69213,"featured_media":25159,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[3],"tags":[84],"class_list":["post-2199","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-microsoft-graph","tag-30daysmsgraph"],"acf":[],"blog_post_summary":"<p>In todays post we will show you how to make Microsoft Graph API calls using Microsoft Flow.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/2199","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\/69213"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/comments?post=2199"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/2199\/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=2199"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/categories?post=2199"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/tags?post=2199"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}