使用 PHP 和 Microsoft Graph API,我通过查询来获取用户:
https://graph.windows.net/<tenant>/users/<userId>?api-version=2013-11-08
这工作正常,但只返回用户对象的标准字段。根据文档,我应该能够使用 $select=* 来获取所有用户数据,如下所示:
https://graph.windows.net/<tenant>/users/<userId>?$select=*&api-version=2013-11-08
但是这给了我以下错误:
{"odata.error":{"code":"Request_BadRequest","message":{"lang":"en","value":"The ability to use the $select query option to define a projection in a data service query is disabled. To enable this functionality, set the DataServiceConfiguration. AcceptProjectionRequests property to true."}}}
如何启用“AcceptProjectionRequests”?我在文档或其他 SO 线程中没有找到任何关于此的信息。
最佳答案
您在上面引用的 API 是 Azure AD Graph,它与 Microsoft Graph APIs 不同。您可能值得花时间查看 Microsoft Graph API 并考虑从 Azure AD Graph 过渡。 Azure AD Graph 团队的一般指南建议使用 Microsoft Graph 而不是 Azure AD Graph。您可以阅读有关差异和 Azure AD 指南的更多信息 here .
话虽如此,Azure AD Graph 不支持 $select(如我上面链接的博客文章中所述)。 Microsoft Graph 确实支持 $select 进行查询投影(请参阅 Microsoft Graph or Azure AD )。
Currently (as of 7/8/2016) Microsoft Graph supports most of the directory features that Azure AD Graph supports, but not all. In some cases, Microsoft Graph supports functionality that is not in Azure AD Graph (such as ability to make $select projection queries).
根据 OData 规范,$select=* 可以返回所有实体属性或默认属性集(前提是默认集包含所有关键属性)。 Microsoft Graph 实现是后者,它将返回一组关键属性。为了获得您需要的所有必要属性,您需要显式请求您想要的整个列表,除非它们恰好在默认集中。
关于office365api - 使用 Microsoft Graph API 获取所有用户数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38953383/