Microsoft Graph – Frequently used Graph API Queries for User – Discussing User object / User Resource Type – Part 2

Hi All,
Greetings for the day!!!
As we are compiling frequently used Microsoft Graph APIs.
In last article we discussed – listing all queries related to users count and users listing. All these queries are “Get” – Microsoft Graph – Frequently used Graph API Queries for Users – Part 1
In this series of articles today we are listing important queries related to only user object. All these queries are “Get“. There are many but here tried to have few.
Also explore different parameters to Graph queries like – Select
- Microsoft Graph enables us full control over the lifecycle of users in Microsoft 365 including creating, updating, and deleting users and to listing users in the organization
Prerequisites
- Basic knowledge of REST services & APIs
- Basic knowledge of Microsoft Graph – Visit our articles to know more about Microsoft Graph APIs – https://knowledge-junction.in/?s=microsoft+graph
- Access to a Microsoft 365 tenant – If you don’t have tenant you can join – Microsoft 365 Developer Program
Bit about User object / User resource type
- Represents an Azure Active Directory (Azure AD) user account
- Inherits from directoryObject.
API Permission required for getting user details
Permission type | Permissions (from least to most privileged) |
---|---|
Delegated (work or school account) | User.Read, Directory.Read.All |
Delegated (personal Microsoft account) | User.Read |
Application | User.Read.All, Directory.Read.All |
- The
User.Read
permission allows the app to read the profile, and discover relationships such as the group membership, reports and manager of the signed-in user only
Get current signed in user details
- Method : GET
https://graph.microsoft.com/v1.0/me
Details :
- By default this API returns only default set of following properties
- businessPhones
- displayName
- givenName
- jobTitle
- mobilePhone
- officeLocation
- preferredLanguage
- surname
- userPrincipalName
- We will use
$select
to get the other properties and relationships for the user object. - Following properties are returned only on $select
accountEnabled | ageGroup | assignedLicenses | companyName |
assignedPlans | birthday | city | consentProvidedForMinor |
country | createdDateTime | creationType | deletedDateTime |
department | employeeHireDate | employeeId | employeeOrgData |
aboutMe | employeeType | externalUserState | externalUserStateChangeDateTime |
faxNumber | hireDate | identities | imAddresses |
interests | lastPasswordChangeDateTime | legalAgeGroupClassification | licenseAssignmentStates |
mailboxSettings | mailNickname | mySite | onPremisesDistinguishedName |
onPremisesDomainName | onPremisesExtensionAttributes | onPremisesImmutableId | onPremisesLastSyncDateTime |
onPremisesProvisioningErrors | onPremisesSamAccountName | onPremisesSecurityIdentifier | onPremisesSyncEnabled |
onPremisesUserPrincipalName | otherMails | passwordPolicies | passwordProfile |
pastProjects | postalCode | preferredLanguage | preferredName |
provisionedPlans | proxyAddresses | refreshTokensValidFromDateTime | responsibilities |
schools | skills | signInSessionsValidFromDateTime | state |
streetAddress | usageLocation | userType |
- Calling the
/me
endpoint requires a signed-in user and therefore a delegated permission - Application permissions are not supported when using the
/me
endpoint
To get aboutMe property we need to must use $select. This property value returned only on $select
- Method : GET
https://graph.microsoft.com/v1.0/me?$select=aboutMe

Get photo
- We can set profile photos on user accounts, groups and contacts
- We can use Microsoft Graph APIs to manage / view / download the profile photos
- Profile photos are stored as binary data
- Method : GET
https://graph.microsoft.com/v1.0/me/photo/$value

- We can request certain specific sizes of photos using Microsoft Graph API
- The supported sizes of HD photos are
- 48×48, 64×64, 96×96, 120×120, 240×240, 360×360, 432×432, 504×504, and 648×648
- We can get the metadata of the largest available photo or specify a size to get the metadata for that photo size.
- To get the specific size of photo
https://graph.microsoft.com/v1.0/me/photos/48x48/$value

Get all my planner task
- Method : GET
https://graph.microsoft.com/v1.0/me/planner/tasks
Get all email messages for given user or from shared mail box
- Method : GET
https://graph.microsoft.com/v1.0/users/{email | userid | userPrincipalName }/messages


References:
- Microsoft Graph – Frequently used Graph API Queries for Users – Part 1
- directoryObject resource type
- Microsoft 365 Developer Program
- https://knowledge-junction.in/?s=microsoft+graph
Thanks for reading !! If its worth at least reading once, kindly please like and share !!! SHARING IS CARING 🙂
Enjoy the beautiful life !! Have a FUN !! HAVE A SAFE LIFE !! TAKE CARE 🙂
You must log in to post a comment.