Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using microsoft graph to get users by office location

I am trying to get all users in an office location using Microsoft Graph

I am receiving the following error message:

Unsupported or invalid query filter clause specified for property 'officeLocation' of resource 'User'.

I am using the following uri and filter:

https://graph.microsoft.com/v1.0/users?$filter=officeLocation eq '18/2107'

at the graph explorer here:

https://developer.microsoft.com/en-us/graph/graph-explorer

How can I pull all users for an Office Location?

Thanks!

like image 511
Stephen Dowd Avatar asked Oct 14 '17 22:10

Stephen Dowd


People also ask

What is Microsoft Graph API used for?

The Microsoft Graph API is a RESTful web API that enables you to access Microsoft Cloud service resources. After you register your app and get authentication tokens for a user or service, you can make requests to the Microsoft Graph API.

Is Microsoft Graph deprecated?

Microsoft Graph is also more secure and resilient than Azure AD Graph. For this reason, Azure AD Graph has been on a deprecation path since June 30, 2020, and will be retired in the near future as we move all investments to Microsoft Graph.

What is Microsoft Graph Explorer?

Graph Explorer is a developer tool that lets you conveniently make Microsoft Graph REST API requests and view corresponding responses. Use Graph Explorer to try APIs on the default sample tenant to explore capabilities, or sign in to your own tenant and use it as a prototyping tool to fulfill your app scenarios.

Does Outlook use graph API?

The Microsoft Graph API supports accessing data in users' primary mailboxes and in shared mailboxes. The data can be calendar, mail, or personal contacts stored in a mailbox in the cloud on Exchange Online as part of Microsoft 365, or on Exchange on-premises in a hybrid deployment.


2 Answers

Unfortunately this property on user is not filterable. If this is something important, please file a request for this on Uservoice: https://officespdev.uservoice.com/forums/224641-feature-requests-and-feedback/category/101632-microsoft-graph-o365-rest-apis

Hope this helps,

like image 198
Dan Kershaw - MSFT Avatar answered Oct 16 '22 19:10

Dan Kershaw - MSFT


Filter on officeLocation is not available till date, we can query for all user than can filter out from that based on officeLocation, API will not return all user in one call, Microsoft Graph will continue to return a reference to the next page of data in the @odata:nextLink property with each response until all pages of the result have been read.You can retrieve the next page of results by sending the URL value of the @odata:nextLink property to Microsoft Graph.

like image 2
Bajrang Avatar answered Oct 16 '22 19:10

Bajrang