Graph API: Getting custom metadata fields from an item in an driveItem by file name

Perry Li 11 Reputation points
2021-01-07T20:06:47.347+00:00

In my document library, I have a folder that contains file A, and a subfolder, which contains file B.

I am able to get custom metadata fields from file A by file name and document library id, using: https://graph.microsoft.com/v1.0/drives/{driveId}/root:/{fileA name}/listItem/fields

But I am failing to get custom metadata fields from file B by name. I know you can use the itemId of the file to get its metadata, like so: https://graph.microsoft.com/v1.0/drives/{driveId}/items/{itemId}/listitem/fields

But I want to get the metadata of file B via its fileName. I have tried to find the proper endpoint but couldn't find any from the documentation.

These were my attempts that all failed:
https://graph.microsoft.com/v1.0/drives/{driveId}/items/{folderId}/root:/{fileB name}/listItem/fields
https://graph.microsoft.com/v1.0/drives/{driveId}/items/{folderId}/children/root:/{fileB name}/listItem/fields
https://graph.microsoft.com/v1.0/drives/{driveId}/items/{folderId}/children/root:/{fileB name}/listItem/fields

Any help with this would be appreciated.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,707 questions
{count} votes

1 answer

Sort by: Most helpful
  1. DSi 1 Reputation point
    2022-06-18T16:15:14.597+00:00

    Try this (missing colon):
    https://graph.microsoft.com/v1.0/drives/{driveId}/items/{folderId}/root:/{fileB name}:/listItem/fields

    and this one to select some fields:

    https://graph.microsoft.com/v1.0/drives/{driveId}/items/{folderId}/root:/{fileB name}:/listItem?expand=fields(select=field1,field2)

    0 comments No comments