Unable to fetch Group description through CSOM for SharePoint Online

Abhinav Vashishtha 0 Reputation points
2023-04-26T09:06:40.5033333+00:00

While fetching SharePoint site Groups from SharePoint online using CSOM, I am getting all requested properties for the group except the Description even when the description is nonempty for the SharePoint group.

ClientContext context = new ClientContext("https://{site_url}"); Web web = context.Web; context.Load(web); context.ExecuteQuery(); context.Load(web.SiteGroups, x => x.Include(group => group.Id, group => group.Title, group => group.Users, group => group.Description)); context.ExecuteQuery();

Microsoft 365 and Office | SharePoint Server | For business
Microsoft 365 and Office | SharePoint | Development
Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft 365 and Office | SharePoint Server | Development
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,471 Reputation points Microsoft External Staff
    2023-04-27T01:59:58.1033333+00:00

    Hi @Abhinav Vashishtha

    Per my test, I can retrieve group description by following code, please make a reference

    using (ClientContext clientContext = new ClientContext("http://MyServer/sites/MySiteCollection"))
    {
    // Get all the groups at site level
    GroupCollection oGroupCollection = clientcontext.Web.SiteGroups;
     
    clientcontext.Load(oGroupCollection);
    clientcontext.ExecuteQuery();
     
    // Iterate through each group
    foreach (Group oGroup in oGroupCollection)
    {
    Console.WriteLine("-------------title-------------");
    Console.WriteLine(oGroup.Title);
    Console.WriteLine("-------------Description-------------");
    Console.WriteLine(oGroup.Description);
    }
    }
    
    

    Here is the test result

    User's image

    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.


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.