SharePoint / sp-dev-docs

SharePoint & Viva Connections Developer Documentation
https://docs.microsoft.com/en-us/sharepoint/dev/
Creative Commons Attribution 4.0 International
1.24k stars 1k forks source link

Microsoft Graph API: Selecting nested properties through OData $select does not appear to work #9546

Open jamesmacwhite opened 7 months ago

jamesmacwhite commented 7 months ago

Target SharePoint environment

SharePoint Online

What SharePoint development model, framework, SDK or API is this about?

Microsoft Graph API (SharePoint pages)

Developer environment

N/A

What browser(s) / client(s) have you tested

Additional environment details

OAuth authenticated Microsoft Graph API HTTP requests using Postman.

Describe the bug / error

I'm not sure if this is a bug or limitation currently, but when returning either a single or multiple microsoft.graph.sitePage query response, I am not able to select nested properties for something like the "titleArea".

I can select the whole titleArea in a $select query, but I cannot selectively return just certain keys under this property.

Examples:

Selecting top level keys with $select

https://graph.microsoft.com/beta/sites/{siteId}/pages/microsoft.graph.sitePage?$filter=promotionKind eq 'newsPost'&$orderby=createdDateTime desc&$top=5&$select=id,title,description,webUrl,promotionKind,createdDateTime,lastModifiedDateTime

Selecting the entire titleArea also works but returns all the keys under this which adds weight to the response size.

https://graph.microsoft.com/beta/sites/{siteId}/pages/microsoft.graph.sitePage?$filter=promotionKind eq 'newsPost'&$orderby=createdDateTime desc&$top=5&$select=id,title,description,webUrl,promotionKind,createdDateTime,lastModifiedDateTime,titleArea

Trying to select a single property of the titleArea with dot notation returns no error but this is not returned in the response data

https://graph.microsoft.com/beta/sites/{siteId}/pages/microsoft.graph.sitePage?$filter=promotionKind eq 'newsPost'&$orderby=createdDateTime desc&$top=5&$select=id,title,description,webUrl,promotionKind,createdDateTime,lastModifiedDateTime,titleArea.imageWebUrl

Trying to select a single property using the forward slash notation causes a bad request error.

https://graph.microsoft.com/beta/sites/{siteId}/pages/microsoft.graph.sitePage?$filter=promotionKind eq 'newsPost'&$orderby=createdDateTime desc&$top=5&$select=id,title,description,webUrl,promotionKind,createdDateTime,lastModifiedDateTime,titleArea/imageWebUrl

I asked Co-Pilot and it seems to suggest the two notations should be possible, but neither work with differing results.

Is it possible to select specific keys within the nested property without returning the entire array? As the titleArea is not a navigation property, expand cannot be used.

Please forgive me if I am not understanding the OData syntax/documentation.

Steps to reproduce

Using the sample HTTP requests with OData $select properties outlined in the bug/error description, each result shows the current behaviour.

Expected behavior

The ability to have just a single or subset of properties be returned from the titleArea.

ghost commented 7 months ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.