Graph API - Sharepoint - Getting drive item missing file fields: category and functional area.

LC 31 Reputation points
2022-02-17T03:54:03.62+00:00

I am having some trouble getting specific file fields when pulling Sharepoint data, using the Graph API.

I'm able to successfully pull info using this Graph API endpoint: https://learn.microsoft.com/en-us/graph/api/driveitem-get?view=graph-rest-1.0&tabs=http. I can see the filename, lastModifiedBy, filesize, MIME type, etc.
But, there are some columns/fields missing from the JSON I am receiving that I cannot see how to retrieve from the documentation page.

The drive items are missing the 'Functional Area' and 'Category' columns, and I've tried appending ?$expand=fields onto the fetch URL, but that also doesn't return what I am after.

Here in this image you can see the fields I am after. I didn't set up this Sharepoint instance, so I am unsure if these are custom columns or not. But if they are, are we able to pull custom columns?

175110-sharepointgetdriveiteminfo.png

Any help would be appreciated.
Thanks.

Microsoft 365 and Office SharePoint Development
Microsoft Security Microsoft Graph
{count} votes

Accepted answer
  1. JanardhanaVedham-MSFT 3,566 Reputation points
    2022-02-17T09:53:32.867+00:00

    Hi @LC ,

    You can be able to fetch custom columns of SharePoint document libraries in multple ways. Since you are get Drive Item API , you can simply append ?expand=listItem paraemter to the query to fetch the custom columns data of a drive item or list item as mentioned below :

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

    Example :

    175381-image.png
    175372-image.png

    GET https://graph.microsoft.com/v1.0/sites/{site-id}/drives/{drive-id}/items/{item-id}?expand=listItem  
    

    175384-image.png

    Alternatively, you can also use the below get list item SharePoint Graph API to drive or list item details including the column columns,

    GET https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{item-id}  
    GET https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{item-id}?expand=fields  
    GET https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{item-id}?expand=fields(select=Column1,Column2)  
    

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.

    2 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,471 Reputation points Microsoft External Staff
    2022-02-17T07:56:12.343+00:00

    Hi @LC ,
    I tested the following url and get the custom column

    GET /sites/{site-id}/lists/{list-id}/items/{item-id}  
    

    175322-image.png
    175216-image.png


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.