How to get custom column value from a SharePoint Document library

Hanz Tay 25 Reputation points
2024-06-12T09:02:07.6933333+00:00

Hi,

I am trying to get a custom column value using the code below. However, it does not return the custom column

var result = await _appClient.Groups[{{GroupId}}].Sites["root"].Lists[{{ListId}}].Items.GetAsync((requestConfiguration) => {     requestConfiguration.QueryParameters.Expand = ["fields"]; });

I ran the below code to check for my list columns and my custom columns do appear

await _appClient.Groups[{{GroupId}}].Sites["root"].Lists[{{listId}}].Columns.GetAsync();

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,253 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,783 questions
0 comments No comments
{count} votes

Accepted answer
  1. RaytheonXie_MSFT 33,176 Reputation points Microsoft Vendor
    2024-06-13T02:30:09.0933333+00:00

    Hi @Hanz Tay,

    You could use following code to get sharepoint list item

    // Code snippets are only available for the latest version. Current version is 5.x
    // To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
    var result = await graphClient.Sites["{site-id}"].Lists["{list-id}"].Items["{listItem-id}"].GetAsync((requestConfiguration) =>
    {
    	requestConfiguration.QueryParameters.Expand = new string []{ "fields" };
    });
    
    
    

    Reference

    https://video2.skills-academy.com/en-us/graph/api/listitem-get?view=graph-rest-1.0&tabs=http


    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 additional answers

Sort by: Most helpful