web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Access to Sharepoint using Microsoft Graph API from Dynamics CRM Custom Workflow Activity

(2) ShareShare
ReportReport
Posted on by 4
I'm trying to read files from SharePoint folder using the Microsoft Graph API inside Custom Workflow activity Dynamics CRM online, getting below error when trying to get SiteId, Unable to create an instance of type Microsoft.Graph.ItemReference
Code:
public string GetSiteId()
{
    var rootSite = _graphClient.Sites[$"{_rootSiteUrl}"];
    var siteResult = rootSite.Request().GetAsync();
    if (siteResult != null)
        return siteResult.Result.Id;
    return string.Empty;
}
 
Please refer to the attached for error details.
I have the same question (0)
  • Verified answer
    Hamza H Profile Picture
    1,826 Super User 2026 Season 1 on at
    The error "Unable to create an instance of type Microsoft.Graph.ItemReference" usually happens because the SDK expects a fully qualified identifier or the format is incorrect.
    For getting SiteId from a URL, use this approach instead:
    var site = await _graphClient.Sites
        .GetByPath(_rootSiteUrl, "root")
        .Request()
        .GetAsync();
    
    return site.Id;

    Or if you have the hostname and site path separately:
    var site = await _graphClient.Sites["{hostname}:/sites/{site-path}"]
        .Request()
        .GetAsync();
    return site.Id;



    Make sure _rootSiteUrl only contains the relative path or the hostname correctly.
    Also, ensure async calls are awaited properly, don’t mix .Result with async.
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 180 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 123

#3
CU11031447-0 Profile Picture

CU11031447-0 100

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans