Graph Search API for a guest: only file entity types
When the signed-in user is a guest (B2B) in the tenant, POST /search/query works for files (driveItem, listItem) but fails for chatMessage, message, event, person and the answer types with 400 BadRequest "SearchRequest Invalid (Guest access is only supported for File entity types. Please remove other entity types from your request.)". It is a documented platform limitation — no admin consent, licence or retry fixes it. Detect the message and tell the user plainly, or don't offer those sources to guests at all.
Host (B2B) smí přes Graph Search prohledávat jen soubory. Chaty Teams, pošta, kalendář i lidé vrátí 400 „Guest access is only supported for File entity types“. Není to souhlas správce ani licence – je to omezení platformy. Hlášku rozpoznej a řekni ji lidsky, nebo hostům tyto zdroje nenabízej.
Symptom
An app that searches several Microsoft 365 sources on the user's behalf (an AI assistant, a unified search box) works for members, but for one account the Teams-chat source always fails:
HTTP 400 · BadRequest: SearchRequest Invalid (Guest access is only supported
for File entity types. Please remove other entity types from your request.)
The same account searches SharePoint/OneDrive files fine. Because the call is a delegated Graph call with Chat.Read / Mail.Read / Calendars.Read consented, the first suspicion is consent or a missing Teams licence — both are wrong.
Cause
Microsoft documents it in the Search API known limitations: guest search doesn't support searches for acronym, bookmark, message, chatMessage, event, person, qna, or externalItem (Search API overview — Known limitations). A guest also usually has no mailbox in the resource tenant, so mail and calendar would be empty anyway.
What to do
- Classify the error by its text, not by status. A 400 normally means "your request is wrong"; here it means "this account can't search this source". Match
Guest access is only supported for File entity typesand show a human sentence, e.g. "This is a guest account from another organization — Microsoft 365 lets guests search only files, not Teams chats, mail or calendar." - Don't send generic consent advice ("ask your admin to approve Chat.Read") for this error — it sends the admin hunting for a problem that doesn't exist.
- Optionally skip non-file entity types up front for guests (user principal name contains
#EXT#, oruserType eq 'Guest'from/me?$select=userType) and grey out those sources with the same explanation. - Keep file search on. Files still work for the guest, limited by the SharePoint permissions they were given.