Skip to content

Instantly share code, notes, and snippets.

@fabianwilliams-zz
Created May 22, 2017 13:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabianwilliams-zz/58400794195ab4d97a56ba0165365347 to your computer and use it in GitHub Desktop.
Save fabianwilliams-zz/58400794195ab4d97a56ba0165365347 to your computer and use it in GitHub Desktop.
#Understanding the Graph Metadata Model
https://graph.microsoft.com/beta/$metadata
#Get Information about Users
https://graph.microsoft.com/v1.0/users/admin@fwilliams.onmicrosoft.com
#Now try it with Beta
https://graph.microsoft.com/beta/users/admin@fwilliams.onmicrosoft.com
https://graph.microsoft.com/beta/users/adelev@fwilliams.onmicrosoft.com
#Now try it and pull only certain properties
https://graph.microsoft.com/beta/users/adelev@fwilliams.onmicrosoft.com?$select=displayName,aboutMe,skills
#You can find out AD or User Relationships
https://graph.microsoft.com/v1.0/users/adelev@fwilliams.onmicrosoft.com/directReports
#you can also get the manager
https://graph.microsoft.com/v1.0/users/adelev@fwilliams.onmicrosoft.com/manager
### YOU CAN EVEN CREATE A MANAGER -- BUT --- you cannot create a direct report using Graph
ttps://graph.microsoft.com/v1.0/users/{id}/manager/$ref
Content-length: xxx
{
"@odata.id": "https://graph.microsoft.com/v1.0/users/{id}"
}
##Create A User
##Note this will FAIL becuase in my APP i DID NOT give it permission to create users
POST https://graph.microsoft.com/v1.0/users
Content-type: application/json
{
"accountEnabled": true,
"displayName": "Techorama User One",
"mailNickname": "TechOUserOne",
"userPrincipalName": "techoramauserone2017@onmicrosoft.com",
"passwordProfile" : {
"forceChangePasswordNextSignIn": true,
"password": "TechoramaBE2017User1"
}
}
#Working with Files
https://graph.microsoft.com/beta/me/drive/root/children
#OneDrive Listing Contents
https://graph.microsoft.com/v1.0/me/drive/root/children?$select=name
##Working with Photos
https://graph.microsoft.com/v1.0/me/photo/$value
https://graph.microsoft.com/v1.0/users/{id | userPrincipalName}/photo/$value
https://graph.microsoft.com/v1.0/groups/{id}/photo/$value
https://graph.microsoft.com/v1.0/me/contacts/{id}/photo/$value
https://graph.microsoft.com/v1.0/users/{id | userPrincipalName}/contacts/{id}/photo/$value
https://graph.microsoft.com/v1.0/me/contactfolders/{contactFolderId}/contacts/{id}/photo/$value
https://graph.microsoft.com/v1.0/users/{id | userPrincipalName}/contactfolders/{contactFolderId}/contacts/{id}/photo/$value
##Working with CONTACTS .. not users NO AD
#List Contacts
https://graph.microsoft.com/v1.0/me/contacts
#notice the K2 one? ??
#Create Contact
{
"givenName": "Andrew",
"surname": "Connell",
"emailAddresses": [
{
"address": "ac@fwilliams.onmicrosoft.com",
"name": "Andrew Connell Jr."
}
],
"businessPhones": [
"+1 914 555 1212"
]
}
#Working with Mail / Messages
https://graph.microsoft.com/v1.0/me/send Mail
POST https://graph.microsoft.com/v1.0/me/sendMail
Content-type: application/json
Content-length: 512
{
"message": {
"subject": "How are you enjoying Techorama so far?",
"body": {
"contentType": "Text",
"content": "Plese let me know your thoughts?."
},
"toRecipients": [
{
"emailAddress": {
"address": "fabian@me.com"
}
}
],
"ccRecipients": [
{
"emailAddress": {
"address": "adelev@fwilliams.onmicrosoft.com"
}
}
]
},
"saveToSentItems": "false"
}
## Working with Calendars / Events
#List YOUR events
https://graph.microsoft.com/v1.0/me/events
#Create an Event
Prefer: outlook.timezone="Eastern Standard Time"
Content-type: application/json
Content-length: 600
{
"subject": "Let's go for lunch",
"body": {
"contentType": "HTML",
"content": "Does late morning work for you?"
},
"start": {
"dateTime": "2017-04-15T12:00:00",
"timeZone": "Eastern Standard Time"
},
"end": {
"dateTime": "2017-04-15T14:00:00",
"timeZone": "Eastern Standard Time"
},
"location":{
"displayName":"Jailbreak Brewing Co"
},
"attendees": [
{
"emailAddress": {
"address":"adelev@fwilliams.onmicrosoft.com",
"name": "Adele Vance"
},
"type": "required"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment