30DaysMSGraph – Day 5 – Query Parameters Part 1

Brian T. Jackett

List of all posts in the #30DaysMSGraph series

In day 4 we discussed the syntax for Microsoft Graph requests.  Today we’ll begin looking at query parameters available for requests against Microsoft Graph.  For a full listing of the query parameters available and additional information / examples please see the full documentation: Use query parameters to customize responses.


Filter is one of the more common query parameters that you may use or encounter.  Filter retrieves a subset of rows from the total results that match the specified conditions.



Ex. – Get users whose display name starts with “A”




Select allows for retrieving a subset or superset of properties rather than the default properties.  This can be especially helpful if you are returning many records that have a high number of default properties returned.  Reduce memory usage and network bandwidth usage by limiting the number of properties returned to only the ones that your app needs.



Ex. – Get name, size, and webUrl of logged in user’s OneDrive site files




OrderBy will sort the results returned from a query using the specified property.  Certain APIs do support multiple properties to sort on.



Ex. – Get logged in user’s contacts sorted by birthday (default ascending)



Additionally, you can specify ascending or descending order by appending a space plus “asc” (default in most cases) or “desc” to the property name.

Ex. – Get logged in user’s contacts sorted by birthday descending.

https://graph.microsoft.com/v1.0/me/contacts?$orderby=birthday desc



Specific endpoints from Microsoft Graph will offer the ability to return results in different formats.  This might include CSV (comma separated value) downloadable files, JSON (JavaScript object notation), or other popular formats.  Endpoints that support the Format query parameter will default to one format but allow alternate supported formats to be requested.



Ex. – Get report of Office 365 Group activity in JSON format


Ex. – Get report of Office 365 Group activity in CSV format


Note: To properly test out this call you will need to log into the Graph Explorer as an Office 365 Global Administrator or an Azure AD Administrator who can grant OAuth permissions to an account.  For the time being simply note the syntax.


Try It Out

Use the query parameters covered today to filter, sort, and specify columns.  Navigate to the Graph Explorer.  Execute the following commands.

Day 5 repo link

  1. Get logged in user’s high priority emails.
    • https://graph.microsoft.com/v1.0/me/messages?$filter=importance eq ‘High’
  2. Get name, size, and webUrl of logged in user’s OneDrive site files.
    • https://graph.microsoft.com/v1.0/me/drive/root/children?$select=name,size,webUrl
  3. Get logged in user’s contacts sorted by birthday.
    • https://graph.microsoft.com/v1.0/me/contacts?$orderby=birthday


Join us tomorrow as we continue with query parameters available for Microsoft Graph requests in Day 6.

Feedback usabilla icon