Expand DriveItem’s listItem property while selecting fields from listItem

I’ve been using Graph for quite some time now and it seems I have found an inconsistent behavior (or gap/bug).

As I described in my answer to a previous post here, the below graph query works.

https://graph.microsoft.com/v1.0/drives/{{drive-id}}/items/{{folder-id}}/children?$expand=listItem

and it returns something like:

{
    "@odata.context": "...",
    "@odata.nextLink": "...":,
    "@microsoft.graph.tips": "Use $select to choose only the properties your app needs, as this can lead to performance improvements. For example: GET drives('<key>')/items('<key>')/children?$select=audio,bundle",
    "value": [
       {
            "@microsoft.graph.downloadUrl": "...",
            "createdDateTime": "2024-08-05T17:36:38Z",
            "eTag": ""{....},1"",
            "id": "....",
            "createdBy: "{...}",
            "lastModifiledBy: "{...}",
            "parentReference": {
                "driveType": "documentLibrary",
                "driveId": "...",
                "id": "...",
                "name": "1213458",
                "path": "/drives/.../root:/1213458",
                "siteId": "..."
            },
            "file": {
                "mimeType": "application/vnd.ms-outlook",
                "hashes": {
                    "quickXorHash": "X3HpXmd2MnjSz+sx2rdXQMlxQhQ="
                }
            },
            "fileSystemInfo": {
                "createdDateTime": "2024-08-05T17:36:38Z",
                "lastModifiedDateTime": "2024-08-05T17:36:38Z"
            },
            "shared": {
                "scope": "users"
            },
            "[email protected]": "...",
            "listItem": {
                "@odata.etag": ""...,1"",
                "createdDateTime": "2024-08-05T17:36:38Z",
                "eTag": ""...,1"",
                "id": "109",
                "lastModifiedDateTime": "2024-08-05T17:36:38Z",
                "webUrl": "...",
                "createdBy": {...},
                "lastModifiedBy": {...},
                "parentReference": {
                    "id": "...",
                    "siteId": "..."
                },
                "contentType": {...},
                "[email protected]": "https://graph.microsoft.com/v1.0/.../listItem/fields/$entity",
                "fields": {
                    **{{ fields and custom fields here }}**
                }
            }
        },
       ...

Now, if I try to trim the properties returned to return just driveItem.id, driveItem.listItem.id, and driveItem.listItem.fields, I get this:

Graph query:

https://graph.microsoft.com/v1.0/drives/{{drive-id}}/items/{{folder-id}}/children?$expand=listItem($select=id,fields)&$select=id,listItem

And the results:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives('b%21QLkUIRN41EGxyL2ze-FcYpwt-281sa5Oj2fmTfCb89X6zP6Qd-aaR79wRgAD_pwn')/items('01IHAJKCDCVMH3EXQARVCI5PEFK7TEKYFL')/children(id,listItem,listItem(id,fields))",
    "@odata.nextLink": "https://graph.microsoft.com/v1.0/drives/b!QLkUIRN41EGxyL2ze-FcYpwt-281sa5Oj2fmTfCb89X6zP6Qd-aaR79wRgAD_pwn/items/01IHAJKCDCVMH3EXQARVCI5PEFK7TEKYFL/children?$expand=listItem(%24select%3did%2cfields)&$select=id%2clistItem&$skiptoken=UGFnZWQ9VFJVRSZwX0ZpbGVMZWFmUmVmPTk2MjU3OTk0X0xvc3MrUnVuK1JlcG9ydCstK0F1ZGF4Lm1zZyZwX0lEPTQ4Nw",
    "value": [
        {
            "@odata.etag": ""{FF50F7F6-DC36-43D1-B952-79272B3C4F2B},1"",
            "id": "01IHAJKCHW65IP6NW42FB3SUTZE4VTYTZL",
            "[email protected]": "https://graph.microsoft.com/v1.0/.../listItem(id,fields)/$entity",
            "listItem": {
                "@odata.etag": ""...,1"",
                "id": "109"
            }
        },
        ...

As you can see, the fields property is not included in the results.

Similarly, this works just fine:

Graph query:

https://graph.microsoft.com/v1.0/sites/{{site-id}}/lists/{{list-id}}/items?$expand=fields($select=id,FileLeafRef)&$select=id,fields

Here are the results, which include the fields property (hence, inconsistent with the previous result):

{
    "@odata.context": "https://graph.microsoft.com/v1.0/.../items(id,fields,fields(id,FileLeafRef))",
    "@odata.nextLink": "...",
    "value": [
        {
            "@odata.etag": ""...,3"",
            "id": "1",
            "[email protected]": "https://graph.microsoft.com/v1.0/.../fields(id,FileLeafRef)/$entity",
            "fields": {
                "@odata.etag": ""caf3311d-1de9-4a89-b2a0-5aaa9ac93de0,3"",
                "id": "1",
                "FileLeafRef": "..."
            }
        },
        {
            "@odata.etag": ""...,1"",
            "id": "2",
            "[email protected]": "https://graph.microsoft.com/v1.0/.../fields(id,FileLeafRef)/$entity",
            "fields": {
                "@odata.etag": ""...,1"",
                "id": "2",
                "FileLeafRef": "..."
            }
        },
        ...

I know there’s some mixing of listItem and driveItem types and properties involved in the first part.

My questions is:

Is there a way of querying Graph to:

  • get files in a folder (seems to have to be through the drive endpoint);
  • while also getting each driveItem’s listItem property (i.e.: $expand=listItem);
  • and also trim the properties of listItem to include only a subset containing listItem.fields in the results (i.e.: $expand=listItem($select=col1,col2,fields))

???

You need to expand fields inside the listItem, because fields is a relationship, not a regular property of the listItem resource.

GET https://graph.microsoft.com/v1.0/drives/{drive_id}/items/{drive_item_id}?&expand=listitem($select=id;$expand=fields)&$select=id,listItem

To return only specific fields, you can use nested $select

GET https://graph.microsoft.com/v1.0/drives/{drive_id}/items/{drive_item_id}?&expand=listitem($select=id;$expand=fields($select=id,FileLeafRef))&$select=id,listItem

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Expand DriveItem’s listItem property while selecting fields from listItem

I’ve been using Graph for quite some time now and it seems I have found an inconsistent behavior (or gap/bug).

As I described in my answer to a previous post here, the below graph query works.

https://graph.microsoft.com/v1.0/drives/{{drive-id}}/items/{{folder-id}}/children?$expand=listItem

and it returns something like:

{
    "@odata.context": "...",
    "@odata.nextLink": "...":,
    "@microsoft.graph.tips": "Use $select to choose only the properties your app needs, as this can lead to performance improvements. For example: GET drives('<key>')/items('<key>')/children?$select=audio,bundle",
    "value": [
       {
            "@microsoft.graph.downloadUrl": "...",
            "createdDateTime": "2024-08-05T17:36:38Z",
            "eTag": ""{....},1"",
            "id": "....",
            "createdBy: "{...}",
            "lastModifiledBy: "{...}",
            "parentReference": {
                "driveType": "documentLibrary",
                "driveId": "...",
                "id": "...",
                "name": "1213458",
                "path": "/drives/.../root:/1213458",
                "siteId": "..."
            },
            "file": {
                "mimeType": "application/vnd.ms-outlook",
                "hashes": {
                    "quickXorHash": "X3HpXmd2MnjSz+sx2rdXQMlxQhQ="
                }
            },
            "fileSystemInfo": {
                "createdDateTime": "2024-08-05T17:36:38Z",
                "lastModifiedDateTime": "2024-08-05T17:36:38Z"
            },
            "shared": {
                "scope": "users"
            },
            "[email protected]": "...",
            "listItem": {
                "@odata.etag": ""...,1"",
                "createdDateTime": "2024-08-05T17:36:38Z",
                "eTag": ""...,1"",
                "id": "109",
                "lastModifiedDateTime": "2024-08-05T17:36:38Z",
                "webUrl": "...",
                "createdBy": {...},
                "lastModifiedBy": {...},
                "parentReference": {
                    "id": "...",
                    "siteId": "..."
                },
                "contentType": {...},
                "[email protected]": "https://graph.microsoft.com/v1.0/.../listItem/fields/$entity",
                "fields": {
                    **{{ fields and custom fields here }}**
                }
            }
        },
       ...

Now, if I try to trim the properties returned to return just driveItem.id, driveItem.listItem.id, and driveItem.listItem.fields, I get this:

Graph query:

https://graph.microsoft.com/v1.0/drives/{{drive-id}}/items/{{folder-id}}/children?$expand=listItem($select=id,fields)&$select=id,listItem

And the results:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives('b%21QLkUIRN41EGxyL2ze-FcYpwt-281sa5Oj2fmTfCb89X6zP6Qd-aaR79wRgAD_pwn')/items('01IHAJKCDCVMH3EXQARVCI5PEFK7TEKYFL')/children(id,listItem,listItem(id,fields))",
    "@odata.nextLink": "https://graph.microsoft.com/v1.0/drives/b!QLkUIRN41EGxyL2ze-FcYpwt-281sa5Oj2fmTfCb89X6zP6Qd-aaR79wRgAD_pwn/items/01IHAJKCDCVMH3EXQARVCI5PEFK7TEKYFL/children?$expand=listItem(%24select%3did%2cfields)&$select=id%2clistItem&$skiptoken=UGFnZWQ9VFJVRSZwX0ZpbGVMZWFmUmVmPTk2MjU3OTk0X0xvc3MrUnVuK1JlcG9ydCstK0F1ZGF4Lm1zZyZwX0lEPTQ4Nw",
    "value": [
        {
            "@odata.etag": ""{FF50F7F6-DC36-43D1-B952-79272B3C4F2B},1"",
            "id": "01IHAJKCHW65IP6NW42FB3SUTZE4VTYTZL",
            "[email protected]": "https://graph.microsoft.com/v1.0/.../listItem(id,fields)/$entity",
            "listItem": {
                "@odata.etag": ""...,1"",
                "id": "109"
            }
        },
        ...

As you can see, the fields property is not included in the results.

Similarly, this works just fine:

Graph query:

https://graph.microsoft.com/v1.0/sites/{{site-id}}/lists/{{list-id}}/items?$expand=fields($select=id,FileLeafRef)&$select=id,fields

Here are the results, which include the fields property (hence, inconsistent with the previous result):

{
    "@odata.context": "https://graph.microsoft.com/v1.0/.../items(id,fields,fields(id,FileLeafRef))",
    "@odata.nextLink": "...",
    "value": [
        {
            "@odata.etag": ""...,3"",
            "id": "1",
            "[email protected]": "https://graph.microsoft.com/v1.0/.../fields(id,FileLeafRef)/$entity",
            "fields": {
                "@odata.etag": ""caf3311d-1de9-4a89-b2a0-5aaa9ac93de0,3"",
                "id": "1",
                "FileLeafRef": "..."
            }
        },
        {
            "@odata.etag": ""...,1"",
            "id": "2",
            "[email protected]": "https://graph.microsoft.com/v1.0/.../fields(id,FileLeafRef)/$entity",
            "fields": {
                "@odata.etag": ""...,1"",
                "id": "2",
                "FileLeafRef": "..."
            }
        },
        ...

I know there’s some mixing of listItem and driveItem types and properties involved in the first part.

My questions is:

Is there a way of querying Graph to:

  • get files in a folder (seems to have to be through the drive endpoint);
  • while also getting each driveItem’s listItem property (i.e.: $expand=listItem);
  • and also trim the properties of listItem to include only a subset containing listItem.fields in the results (i.e.: $expand=listItem($select=col1,col2,fields))

???

You need to expand fields inside the listItem, because fields is a relationship, not a regular property of the listItem resource.

GET https://graph.microsoft.com/v1.0/drives/{drive_id}/items/{drive_item_id}?&expand=listitem($select=id;$expand=fields)&$select=id,listItem

To return only specific fields, you can use nested $select

GET https://graph.microsoft.com/v1.0/drives/{drive_id}/items/{drive_item_id}?&expand=listitem($select=id;$expand=fields($select=id,FileLeafRef))&$select=id,listItem

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật