Retrieving Custom Columns with File Details using Microsoft Graph API in SharePoint

Almaany, Omar 1 Reputation point
2023-05-23T19:08:01.3633333+00:00

Is it possible to fetch custom columns in conjunction with file details from a SharePoint site using Microsoft Graph APIs? I've been able to retrieve file details successfully but the custom columns aren't being returned in the data.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
1,308 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Sayantan Ganguly 1,145 Reputation points
    2023-05-29T06:29:51.6533333+00:00

    Hello Almaany, Omar,

    Thanks for reaching out!

    Yes, it is possible to fetch custom columns along with file details from a SharePoint site using Microsoft Graph APIs. When retrieving file details using the Microsoft Graph API, you can include the $expand query parameter to expand the custom columns associated with the file.

    To fetch custom columns, you need to make use of the SharePoint-specific properties. Here's an example API request to retrieve file details along with custom columns:

    GET https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{item-id}?$expand=fields
    

    In the above request, you need to replace {site-id}, {list-id}, and {item-id} with the actual IDs for your SharePoint site, list, and item respectively. The $expand=fields query parameter is used to include the custom column values associated with the item.

    The response will include the custom column values in the fields property of the item. Each custom column will have its own property within the fields object.

    Make sure that you have the necessary permissions to access the SharePoint site and retrieve custom column data. Additionally, ensure that the custom columns are associated with the list and the items have values for those columns.

    By including the $expand=fields query parameter, you should be able to fetch custom columns along with file details from a SharePoint site using Microsoft Graph APIs.

    Hope this helps.

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

    0 comments No comments