Microsoft Graph API
Mike Peat - Unicorn InterGlobal, UK
What is Microsoft Graph?
What is Microsoft Graph?
A bit of history
OAuth2
Microsoft 365 API
Microsoft 365 API
Dealing with JSON - old style
Struct tO365CalEvents
String _odata_context
Procedure Construct_Object
Property String psMap__odata_context "_odata_context"
Procedure JsonToStruct tJsonNode strJson tO365Calevents ByRef strValue
String sMemberName sSimpleValue
Get psMap__odata_context to sMemberName
If (sMemberName <> "") Begin
Get ObjectMemberSimple of oJsonFunctions strJson sMemberName ;
to sSimpleValue
Get StringFromString of oSimpleTypeStringConversions sSimpleValue ;
to strValue._odata_context
End
Extracting just one scalar element of the JSON to a struct member:
Dealing with JSON - old style
Managing MS 365 requests
Code for GetEvents in MS 365
Function GetEvents String sCalendarID tO365CalEvents ByRef tEvents String sParams ;
Returns Boolean
String sPath
Integer iOK
Send SetForOutlook
Get psOutlookBasePath to sPath
If (sCalendarID = "") ;
Move (sPath + "me/events") to sPath
Else ;
Move (sPath + "me/calendars/" + ;
sCalendarID + "/events") to sPath
If (sParams <> "") ;
Move (sPath + "?" + sParams) to sPath
Set phoOutputTranslator of oBroker to oStructHandler_tO365CalEvents
Set phmOutputTransProc of oBroker to (RefProc(JsonStringToStruct))
Set pbExpectOutput of oBroker to True
Get HandleCall of oBroker "GET" sPath "" (&tEvents) to iOK
Function_Return (iOK = 1)
End_Function
But with our new tools and now for Graph…
So what do we need for MS Graph?
So what do we need for MS Graph?
The same call in the Graph API
Function GetEvents String sCalendar String sParams Returns Handle
Handle hoEvents
String sPath
If (sCalendar = "") ;
Move (GraphPath(Self) + "me/events") to sPath
Else ;
Move (GraphPath(Self) + ;
"me/calendars/" + sCalendar + "/events") to sPath
Get MakeJsonCall of (phoHttp(Self)) "GET" sPath sParams "" to hoEvents
Function_Return hoEvents
End_Function
Almost Trivial!
Structure
Source
OAuth2
cHttpTransferREST
View(s)
MSGraphAPI
Various API functions
Get MakeJsonCall
Get OAuth2AccessToken
Function OAuth2AccessToken
Get wpsAccessToken
Call various
API functions
Login
DEMO
The Graph API is not quite the same
So…
Thank you!
Are there any questions?