Presentation is loading. Please wait.

Presentation is loading. Please wait.

WPC003 - Usare le Microsoft Graph API

Similar presentations


Presentation on theme: "WPC003 - Usare le Microsoft Graph API"— Presentation transcript:

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

2 About Me Fabio Franzini Office Servers & Services MVP
About Me

3 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.

4 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.

5 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.

6 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 © 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.

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

8 Diverse API styles and endpoints
Azure Active Directory Graph API Windows Live profile API SharePoint User Profile API Exchange HD Picture API Outlook REST API Office Graph in SharePoint Online OneDrive for Business API /yina_contoso_com/_api/v2.0/drive /designCouncil/_api/v2./drive OneDrive API

9 Today’s world with Microsoft Graph
Work and school Personal

10 Microsoft Graph development stack

11 Unified API style Microsoft Ignite 2016 10/13/2017 8:35 AM Operation
Service endpoint GET my profile GET my files GET my photo GET my mail GET my calendar GET my manager GET last user to modify file foo.txt GET users in my organization GET group conversations GET people related to me GET my tasks GET my notes GET files trending around me © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

12 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

13 Calling the Microsoft Graph API using REST

14 Calling the Microsoft Graph API
Call and specify the resource URLs using HTTP verbs GET, POST, PATCH, PUT, DELETE URL pattern {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.

15 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

16 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.

17 $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:

18 $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: 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: me/drive/root?$expand=children( $select=id,name)

19 $orderby, $filter $orderby $filter
To specify the sort order of the items returned from the Microsof Graph API, use the $orderby query option Ex: v1.0/users?$orderby=display Name To filter the response data based on a set of criteria, use the $filter query option. v1.0/users?$filter=startswith( displayName,'Garth')

20 $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 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 v1.0/me/events?$orderby=cr eatedDateTime&$skip=20

21 $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 value. Some of them include a $skipToken value. %27 %27

22 $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

23 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

24 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.

25 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.

26 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.

27 Calling the Microsoft Graph API using SDK

28 Microsoft Graph API SDK

29 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

30 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

31 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

32 Microsoft Graph API .NET SDK
Examples

33 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.

34 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

35 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 me/events?$filter=startswith(subject, 'ship')

36 Microsoft Graph API JavaScript SDK
Example of Post Action

37 Microsoft Graph API JavaScript SDK
Example of Delete and Put

38 Microsoft Graph API JavaScript SDK
Example of Optional Parameters

39 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.

40 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.

41 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.

42 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.

43 Questions?

44 Contatti OverNet Education
Tel @overnete Contatti OverNet Education


Download ppt "WPC003 - Usare le Microsoft Graph API"

Similar presentations


Ads by Google