无法从SiteCollection获取DataLocationCode值的Graph API问题求助
我尝试获取任意SharePoint站点的DataLocationCode值,在Graph Explorer中测试了多种OData查询语法(包括简单调用、$select、嵌套$select、$expand)均未成功。我通常使用C# SDK进行简单调用,此次需获取该值用于Search端点,同时借此学习Microsoft Graph的OData查询字符串。以下是各调用及返回结果:
简单调用
请求:
GET https://graph.microsoft.com/v1.0/sites/{siteid}
返回:
{ "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites/$entity", "@microsoft.graph.tips": "Use $select to choose only the properties your app needs, as this can lead to performance improvements. For example: GET sites('<key>')?$select=displayName,error", "createdDateTime": "2023-08-10T15:14:45.583Z", "description": "a_description", "id": "tenant.sharepoint.com,some_guid,some_guid", "lastModifiedDateTime": "2023-08-20T12:10:08Z", "name": "P008-Baltik", "webUrl": "https://tenantname.sharepoint.com/sites/some_name", "displayName": "some site name", "root": {}, "siteCollection": { "hostname": "tenantname.sharepoint.com" } }
$select调用
请求:
GET https://graph.microsoft.com/v1.0/sites/{siteid}?$select=siteCollection
返回:
{ "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites(siteCollection)/$entity", "siteCollection": { "hostname": "tenant.sharepoint.com" } }
嵌套$select调用(尝试)
请求:
GET https://graph.microsoft.com/v1.0/sites/{siteid}?$select=siteCollection/dataLocationCode
返回:
{ "error": { "code": "BadRequest", "message": "Select options are not supported.", "innerError": { "date": "2023-08-28T14:58:15", "request-id": "some_guid", "client-request-id": "some_guid" } } }
$expand调用
请求:
GET https://graph.microsoft.com/v1.0/sites/{siteid}?$expand=siteCollection&select=dataLocationCode
返回:
{ "error": { "code": "BadRequest", "message": "Parsing OData Select and Expand failed: Property 'siteCollection' on type 'microsoft.graph.site' is not a navigation property or complex property. Only navigation properties can be expanded.", "innerError": { "date": "2023-08-28T15:18:10", "request-id": "some_guid", "client-request-id": "some_guid" } } }
内容的提问来源于stack exchange,提问作者Ama
相关产品推荐
相关产品推荐

