Microsoft Graph: Challenges with UserInformationList Search and Filter
Introduction
When working with the UserInformationList in SharePoint via Microsoft Graph, you might encounter challenges when trying to search or filter user information. This post highlights the issues I faced while attempting to use $search
and $filter
queries on the UserInformationList, along with examples and insights within M365 Copilot declarative agent.
Issue 1: Search by Email Did Not Work
I attempted to search for a user by their email address using the $search
query, but it did not return any results. Below is the query I used:
Query:
https://graph.microsoft.com/v1.0/sites/{siteurl}/lists/328462c4-b18a-4a4b-8d3c-6feea2a916bb/items?$search=reshmee%40reshmee.onmicrosoft.com
Result:
The query failed to return any results, even though the email address exists in the UserInformationList.
"error": {
"code": "BadRequest",
"message": "Syntax error: character '@' is not valid at position 7 in 'reshmee@reshmee. onmicrosoft.com' .",
"innerError": {
"date": "2025-04-23T08:11:03",
"request-id": "b4b1e4ab-73fd-4adc-a35f-cbd5cc464a78",
"client-request-id": "cb782864-859f-0b07-b823-9ad62e7b93e3"
Issue 2: Filter by Fields (e.g., Title, FirstName) Did Not Work
I also tried filtering the UserInformationList by specific fields such as FirstName using the $filter query. Unfortunately, this approach also failed to return any results because the fields are not indexed. Being a hidden list, the columns within can’t easily be indexed.
Query
https://graph.microsoft.com/v1.0/sites/{siteUrl}/lists/328462c4-b18a-4a4b-8d3c-6feea2a916bb/items?$filter=fields/FirstName eq 'Reshmee'
Error: “Field ‘FirstName’ cannot be referenced in filter or orderby as it is not indexed. Provide the ‘Prefer: HonorNonIndexedQueriesWarningMayFailRandomly’ header to allow this, but be warned that such queries may fail on large lists.”,
Result: The query did not return any matching items, even though the FirstName field contains the value Reshmee.
Use Case
In the solution I built with Lee Ford, all data from the UserInformationList
is retrieved, and M365 Copilot displays the user’s ID based on the logged-in user. This functionality is critical for providing personalized experiences within the Copilot agent.
If anyone has insights or solutions on how to successfully query the UserInformationList
using Microsoft Graph—especially with $search
or $filter
—please feel free to share your expertise.
Conclusion
The UserInformationList
in SharePoint presents significant challenges when using $search
and $filter
queries via Microsoft Graph. These limitations can hinder efforts to efficiently retrieve user-specific data. While workarounds exist, they often require additional effort or access to alternative APIs.
If you know how to pass the Prefer: HonorNonIndexedQueriesWarningMayFailRandomly
header within an OpenAPI spec or have other solutions, please reach out.