WPC003 - Usare le Microsoft Graph API

Slides:



Advertisements
Similar presentations
08 | Advanced Features Jerry Nixon | Microsoft Developer Evangelist Daren May | President & Co-founder, Crank211.
Advertisements

Course Agenda Deep Dive into the Building Blocks and Services of the SharePoint Platform Module 1: Developing Advanced Workflow Scenarios in Office 365.
SharePoint Online Hybrid Troubleshooting Tips and Tricks Manas Biswas Sr. Support Escalation Engineer, SharePoint Online Escalation Services Microsoft.
Redmond Protocols Plugfest 2016 Andrew Davidoff Mail, Calendar, and Contacts Graph API Demonstration Senior Software Engineer.
Office 365 Upsell Paths.
Yochay Kiriaty Senior Technical Evangelist Microsoft® Corporation
5/13/2018 8:08 AM © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN.
Office 365 Developer Overview
Microsoft Office SharePoint Server 2007 Enterprise Search
5/22/2018 3:04 AM © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN.
5/29/2018 1:51 AM THR2071 Managing enterprise applications, permissions, and consent in Azure Active Directory Adam Steenwyk & Jeff Sakowicz Program Managers.
About Bill Bill Baer (ˈbɛər)
6/1/2018 2:18 AM OSP302 Building Integrated Microsoft Office 365, SharePoint Online, and Office Solutions Using BCS and LOB Data Donovan Follette
Microsoft /4/2018 8:21 AM BRK3082 Build solutions and apps with Microsoft OneDrive API and Microsoft Graph API Ryan Gregg Principal Program Manger,
Office 365 Groups and Planner API - Getting Started
Microsoft Build /9/2018 8:04 PM © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY,
9/11/ :51 AM Cloud Roadshow © 2014 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO.
SaaS Application Deep Dive
Microsoft Ignite /17/2018 4:41 AM BRK4016
6/17/2018 5:54 AM OSP322 Getting the best of both worlds, making the most of SharePoint hybrid search solutions Shyam Narayan Microsoft © 2013 Microsoft.
GET-ting Your Office 365 Data Using the Microsoft Graph API
SharePoint power hour Rob Howard Program Manager Build 2014
PowerApps and Microsoft Flow for Business Users
Customize Office 365 Search and create result sources
Services Course 9/9/2018 3:37 PM Services Course Windows Live SkyDrive Participant Guide © 2008 Microsoft Corporation. All rights reserved.
Azure DevCamp Identity and Office 365 APIs
Microsoft Virtual Academy
SharePoint Online Management and Control
Microsoft Ignite NZ October 2016 SKYCITY, Auckland.
Office 365 Development.
Application Delivery & MAM Policy
Controlling and leveraging the power of the Microsoft Graph
Microsoft Graph for the .NET Developer
Azure AD Line Of Business Application Integration
The Future of SharePoint Development - Vision, Strategy, and Roadmap
Azure Active Directory
Microsoft Connect /15/2018 3:03 AM
11/19/2018 © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks.
Office 365 Development July 2014.
Microsoft Graph- Permissions and Consent
Migrate your apps from legacy APIs to Microsoft Graph
SharePoint User Group Zürich – 1 November 2016.
Office 365 Development July 2014.
Windows Azure Keenan Newton 3-021
Microsoft Ignite /6/2018 6:15 PM
Excel Rest API Sudhi Ramamurthy Program Manager, Office Extensibility
Office 365 Development.
Windows SDK for Facebook
Your Devices + OData + Azure = 
Office 365 Identity Management
12/27/2018 4:59 AM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or.
12/29/2018 8:46 AM © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN.
Microsoft Build /2/2019 6:45 PM © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY,
TechEd /15/2019 8:08 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
Office 365 Development.
Microsoft Build /22/2019 5:32 PM © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY,
TechEd /22/2019 9:22 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
2/23/2019 4:36 AM © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN.
Office 365 Development.
Maxim Lukiyanov Program Manager Microsoft Corporation
Microsoft Office 4/3/2019 Deep Dive into native Universal App development with the Office 365 APIs Speaker name Title Microsoft Corporation © 2012 Microsoft.
Microsoft Build /8/2019 5:13 AM © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY,
Microsoft Ignite NZ October 2016 SKYCITY, Auckland.
Microsoft Graph – Intune API’s
Microsoft Connect /29/2019 4:52 PM
The complete developer's guide to the SkyDrive API
Microsoft Build /7/ :40 AM © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY,
Office 365 Development.
Azure AD Simon May Technical Evangelist.
Presentation transcript:

WPC003 - Usare le Microsoft Graph API Fabio Franzini MVP - Office Servers & Service

About Me Fabio Franzini Office Servers & Services MVP Twitter: @franzinifabio Email: fabio@fabiofranzini.com About Me www.wpc2016.it – info@wpc2016.it - +39 02 365738.11

Agenda Microsoft Graph overview 10/13/2017 Agenda Microsoft Graph overview Calling the Microsoft Graph API using REST Calling the Microsoft Graph API using SDK What’s New in GA and Preview © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Microsoft Graph Overview 10/13/2017 8:35 AM Microsoft Graph Overview © 2014 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Office Platform WHAT CAN I BUILD? ADD-INS AND WEB PARTS: Microsoft Ignite 2016 10/13/2017 8:35 AM Office Platform WHAT CAN I BUILD? ADD-INS AND WEB PARTS: Make your solution a native part of the modern Office WEB AND DEVICE APPS: Build smarter apps by connecting to Office services VOICE, VIDEO, CONNECTORS, AND BOTS: Create the next generation of productivity solutions © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

What is Microsoft Graph? 10/13/2017 What is Microsoft Graph? Single API for: Accessing data /me, /users, /groups, /messages, /drive, …. Traversing data /drive/items/<id>/lastmodifiedByUser Accessing insights /insights/trending Work/School and Personal https://graph.microsoft.com/ © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

State of the world before Microsoft Graph Work and school Personal Many different APIs to access data Separate auth stacks for work and personal

Diverse API styles and endpoints Azure Active Directory Graph API https://graph.windows.net/contoso.com/users https://graph.windows.net/contoso.com/groups Windows Live profile API https://apis.live.net/v5.0/me SharePoint User Profile API https://contoso.sharepoint.com/_api/SP.UserProfiles.PeopleManager/GetMyProperties Exchange HD Picture API https://graph.microsoft.com/v1.0/me/photo Outlook REST API https://outlook.office.com/api/v2.0/me/Messages https://outlook.office.com/api/v2.0/me/Events Office Graph in SharePoint Online https://contoso.sharepoint.com/_api/search/query?Querytext='*'&Properties='GraphQuery:actor(ME,action\:1020,or(action\:1020\,action\:1003,action\:1001,action\:1024,action\:1005,action\:1037,action\:1039,action\:1036)'&SelectProperties='Docid,Title OneDrive for Business API https://contoso-my.sharepoint.com/personal /yina_contoso_com/_api/v2.0/drive https://contoso.sharepoint.com/sites /designCouncil/_api/v2./drive OneDrive API https://api.onedrive.com/v1.0/drive

Today’s world with Microsoft Graph https://graph.microsoft.com Work and school Personal …

Microsoft Graph development stack www.wpc2016.it – info@wpc2016.it - +39 02 365738.11

Unified API style Microsoft Ignite 2016 10/13/2017 8:35 AM 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 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/insights/trending © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

App Autentication To access a user's Microsoft data, your application must enable users to authenticate their identity and give their consent for the app to perform actions on their behalf The Microsoft Graph supports two authentication providers: To authenticate users with personal Microsoft accounts, such as live.com or outlook.com accounts, use the Azure Active Directory (Azure AD) v2.0 endpoint To authenticate users with enterprise (that is, work or school) accounts, use Azure AD www.wpc2016.it – info@wpc2016.it - +39 02 365738.11

Calling the Microsoft Graph API using REST www.wpc2016.it – info@wpc2016.it - +39 02 365738.11

Calling the Microsoft Graph API Call and specify the resource URLs using HTTP verbs GET, POST, PATCH, PUT, DELETE URL pattern https://graph.microsoft.com/{version}/{resource}?[query_parameters] {version} is the target service version, for example, v1.0 or beta. {resource} is resource segment or path, such as: users, groups, devices, organization The alias me, which resolves to the signed-in user The resources belonging to a user, such as me/events, me/drive or me/messages The alias myOrganization, which resolves to the tenant of the organization signed-in user [query_parameters] represents additional query parameters such as $filter and $select Compatible with the OData V4 query language. www.wpc2016.it – info@wpc2016.it - +39 02 365738.11

Microsoft Graph API metadata The metadata allows you to see and understand the data model of the Microsoft Graph, including the entity types and sets, complex types, and enums that make up the request and response packets sent to and from Microsoft Graph https://graph.microsoft.com/v1.0/$metadata https://graph.microsoft.com/beta/$metadata www.wpc2016.it – info@wpc2016.it - +39 02 365738.11

Microsoft Graph query parameters Name Value Description $search string A property and value pair separated by a colon. $select Comma-separated list of properties to include in the response. $expand Comma-separated list of relationships to expand and include in the response. $orderby Comma-separated list of properties that are used to sort the order of items in the response collection. $filter Filters the response based on a set of criteria. $top int The number of items to return in a result set. $skip The number of items to skip in a result set. $skipToken Paging token that is used to get the next set of results. $count none A collection and the number of items in the collection. www.wpc2016.it – info@wpc2016.it - +39 02 365738.11

$search To restrict the results of a request that match a search criterion, use the $search query parameter Search criteria are expressed using Advanced Query Syntax (AQS) The results are sorted by the date and time that the message was sent You can specify the following properties on a message in a $search criterion: attachments, bccRecipients, body, category, ccRecipients, content, from, h asAttachments, participants, receivedDateTime, sender, subject, toRecipients If you do a search on messages and specify only a value, the search is carried out on the default search properties of from, subject and body. Ex: https://graph.microsoft.com/v1.0/me/messages?$search="from:help@contoso.com" www.wpc2016.it – info@wpc2016.it - +39 02 365738.11

$select, $expand $select $expand The $select option allows for choosing a subset or superset of the default set returned. For example, when retrieving your messages, you might want to select that only the from and subject propert ies of messages are returned. Ex: https://graph.microsoft.com/ v1.0/me/messages?$select=f rom,subject You can use the $expand query string parameter to instruct the API to expand a child object or collection and include those results. For example, to retrieve the root drive information and the top level child items in a drive, you use the $expand parameter. This example also uses a $select statement to only return the id and name properties of the children items. Ex: https://graph.microsoft.com/v1.0/ me/drive/root?$expand=children( $select=id,name) www.wpc2016.it – info@wpc2016.it - +39 02 365738.11

$orderby, $filter $orderby $filter To specify the sort order of the items returned from the Microsof Graph API, use the $orderby query option Ex: https://graph.microsoft.com/ v1.0/users?$orderby=display Name To filter the response data based on a set of criteria, use the $filter query option. https://graph.microsoft.com/ v1.0/users?$filter=startswith( displayName,'Garth') www.wpc2016.it – info@wpc2016.it - +39 02 365738.11

$top $skip $top, $skip To specify the maximum number of items to return in a result set, use the $top query option The $top query option identifies a subset in the collection This subset is formed by selecting only the first N items of the set, where N is a positive integer specified by this query option https://graph.microsoft.com/ v1.0/me/messages?$top=5 To set the number of items to skip before retrieving items in a collection, use the $skip query option https://graph.microsoft.com/ v1.0/me/events?$orderby=cr eatedDateTime&$skip=20 www.wpc2016.it – info@wpc2016.it - +39 02 365738.11

$skipToken To request second and subsequent pages of Graph data use the $skipToken query option. The $skipToken query option is an option provided in Urls returned from the Graph when the Graph has returned a partial subset of results, usually due to server-side paging. It identifies the point in a collection where the server finished sending results, and is passed back to the Graph to indicate where it should resume sending results from. For example, the value of a $skipToken query option could identify the tenth item in a collection or the 20th item in a collection containing 50 items, or any other position within the collection. In some responses, you'll see an @odata.nextLink value. Some of them include a $skipToken value. "@odata.nextLink": https://graph.microsoft.com/v1.0/users?$orderby=displayName&$skiptoken=X%278363037210000 0000000000000000%27 https://graph.microsoft.com/v1.0/users?$orderby=displayName&$skiptoken=X%278363037210000 0000000000000000%27 www.wpc2016.it – info@wpc2016.it - +39 02 365738.11

$count Use $count as a query parameter to include a count of the total number of items in a collection alongside the page of data values returned from the Graph https://graph.microsoft.com/v1.0/me/contacts?$count=true www.wpc2016.it – info@wpc2016.it - +39 02 365738.11

Error responses and resource types Errors in Microsoft Graph are returned using standard HTTP status codes JSON error response object that includes all the details of the error www.wpc2016.it – info@wpc2016.it - +39 02 365738.11

Error HTTP status codes 1/2 Status message Description 400 Bad Request Cannot process the request because it is malformed or incorrect. 401 Unauthorized Required authentication information is either missing or not valid for the resource. 403 Forbidden Access is denied to the requested resource. The user might not have enough permission. 404 Not Found The requested resource doesn’t exist. 405 Method Not Allowed The HTTP method in the request is not allowed on the resource. 406 Not Acceptable This service doesn’t support the format requested in the Accept header. 409 Conflict The current state conflicts with what the request expects. For example, the specified parent folder might not exist. 410 Gone The requested resource is no longer available at the server. 411 Length Required A Content-Length header is required on the request. 412 Precondition Failed A precondition provided in the request (such as an if-match header) does not match the resource's current state. www.wpc2016.it – info@wpc2016.it - +39 02 365738.11

Error HTTP status codes 2/2 Status message Description 413 Request Entity Too Large The request size exceeds the maximum limit. 415 Unsupported Media Type The content type of the request is a format that is not supported by the service. 416 Requested Range Not Satisfiable The specified byte range is invalid or unavailable. 422 Unprocessable Entity Cannot process the request because it is semantically incorrect. 429 Too Many Requests Client application has been throttled and should not attempt to repeat the request until an amount of time has elapsed. 500 Internal Server Error There was an internal server error while processing the request. 501 Not Implemented The requested feature isn’t implemented. 503 Service Unavailable The service is temporarily unavailable. 507 Insufficient Storage The maximum storage quota has been reached. 509 Bandwidth Limit Exceeded Your app has been throttled for exceeding the maximum bandwidth cap. www.wpc2016.it – info@wpc2016.it - +39 02 365738.11

DEMO Graph Explorer Microsoft Ignite 2016 10/13/2017 8:35 AM © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Calling the Microsoft Graph API using SDK

Microsoft Graph API SDK

Microsoft Graph API .NET SDK The Microsoft Graph .NET Client Library is built as a Portable Class Library This targets the following frameworks: .NET 4.5 .NET for Windows Store apps Windows Phone 8.1 and higher Installation via NuGet Search for Microsoft.Graph in the NuGet Library Type Install-Package Microsoft.Graph into the Package Manager Console www.wpc2016.it – info@wpc2016.it - +39 02 365738.11

Microsoft Graph API .NET SDK The Microsoft Graph .NET Client Library is made up of 6 major components: A client object An authentication provider An HTTP provider + serializer Request builder objects Request objects Property bag object model classes for serialization and deserialization The library is designed to be highly extensible. This overview covers basic scenarios but many of the individual components can be replaced with custom implementations www.wpc2016.it – info@wpc2016.it - +39 02 365738.11

Microsoft Graph API .NET SDK To begin making requests with the library, you will need to initialize a GraphServiceClient instance for building and sending requests The authentication provider is responsible for authenticating requests before sending them to the service. The Microsoft Graph .NET Client Library doesn't implement any authentication by default You will need to retrieve access tokens for the service via the authentication library of their choice or by coding against one of the authentication endpoints directly www.wpc2016.it – info@wpc2016.it - +39 02 365738.11

Microsoft Graph API .NET SDK Examples www.wpc2016.it – info@wpc2016.it - +39 02 365738.11

DEMO .NET SDK Microsoft Ignite 2016 10/13/2017 8:35 AM © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Microsoft Graph API JavaScript SDK The Microsoft Graph JavaScript SDK is a lightweight wrapper around the Microsoft Graph API that supports both Node and the browser Node npm install msgraph-sdk-javascript Include the library in your JavaScript file with const MicrosoftGraph = require("msgraph-sdk-javascript"); Browser Include graph-js-sdk-web.js in your page www.wpc2016.it – info@wpc2016.it - +39 02 365738.11

Microsoft Graph API JavaScript SDK All calls to Microsoft Graph are chained together starting with client.api(path). Path supports the following formats: me /me https://graph.microsoft.com/v1.0/me https://graph.microsoft.com/beta/me me/events?$filter=startswith(subject, 'ship') www.wpc2016.it – info@wpc2016.it - +39 02 365738.11

Microsoft Graph API JavaScript SDK Example of Post Action www.wpc2016.it – info@wpc2016.it - +39 02 365738.11

Microsoft Graph API JavaScript SDK Example of Delete and Put www.wpc2016.it – info@wpc2016.it - +39 02 365738.11

Microsoft Graph API JavaScript SDK Example of Optional Parameters www.wpc2016.it – info@wpc2016.it - +39 02 365738.11

DEMO JavaScript SDK Microsoft Ignite 2016 10/13/2017 8:35 AM © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

What’s New in GA and Preview Microsoft Ignite 2016 10/13/2017 8:35 AM What’s New in GA and Preview © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

What’s new in GA? Excel API WebHooks for OneDrive Microsoft Ignite 2016 10/13/2017 8:35 AM What’s new in GA? Excel API WebHooks for OneDrive Extend Graph with your own LOB info for Outlook FindMeetingTimes scheduling API © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

What’s new in preview? SharePoint Sites and Lists Microsoft Ignite 2016 10/13/2017 8:35 AM What’s new in preview? SharePoint Sites and Lists Hybrid on-premise support for Outlook @mentions social gestures Simpler query syntax without $ OneDrive large file upload Azure AD Administrative Units Invitation Manager Privileged Identity Management Identity Protection Application proxy © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Questions? www.wpc2016.it – info@wpc2016.it - +39 02 365738.11

Contatti OverNet Education info@overneteducation.it www.overneteducation.it Tel. 02 365738 @overnete www.facebook.com/OverNetEducation www.linkedin.com/company/overnet-solutions www.wpc2016.it Contatti OverNet Education www.wpc2016.it – info@wpc2016.it - +39 02 365738.11