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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

¿How to Upload documents to SharePoint by Development C# in Dynamics 365 Online?

(0) ShareShare
ReportReport
Posted on by 1,088

Does anyone has used Sharepoint Rest API, I need to develop a component "PLUGIN" that automates that task for uploading fles to Sharepoint,

all examples I found uses Other Microsoft Libraries like "Microsoft.SharePoint.Client"(CSOM) so in plugins there is not  way of using those libraries in Dynamics Online, maybe you could merge them but that would be like not supported, so Sharepoint seems to expose a REST API but I'm unable of consuming that.

this is what you could find on google but a 401 error rises.

HttpWebRequest endpointRequest = (HttpWebRequest)WebRequest.Create($"{siteurl}/_api/web/lists");
var s = new System.Security.SecureString();
"abc123".ToList().ForEach(o => s.AppendChar(o));
HttpWebRequest endpointRequesta = (HttpWebRequest)HttpWebRequest.Create("https://test.sharepoint.com/sites/CRM/_api/contextinfo");
endpointRequest.Method = "GET";
endpointRequest.Accept = "application/json;odata=verbose";
NetworkCredential cred = new System.Net.NetworkCredential("admin@trainee4.onmicrosoft.com", s);
endpointRequest.Credentials = cred;
endpointRequest.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f");
HttpWebResponse endpointResponse1 = (HttpWebResponse)endpointRequest.GetResponse();

by the way in line 8 if I do something like this it works

SharePointOnlineCredentials cred= new SharePointOnlineCredentials("admin@test.onmicrosoft.com", s);
endpointRequest.Credentials = cred;

¿So whats the wrong with that? It Uses the Client CSOM -  Microsoft.SharePoint.Client

any example, references links ?

Update 1: I can't use Power Automate.

Update 2: SPO(SharePoint Online) uses "Claims base authentication" so basic auth won't work, will do if uses either SharePointOnlineCredentials or custom implementation Custom claims with cookies, thats it's why it works.

Update 3: Maybe this it's well known but in Sharepoint Online it's recommended the use of an App(SharePoint Add-in) Create and Add-in , I think for this cases (I mean were I can't use PowerAutomate) it's better use that, where it provides the AppID, ClientId and Secret. I'll do it and share some thougths

thanks, Regards.

I have the same question (0)
  • Suggested answer
    Luis Nogueira Profile Picture
    on at

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 74

#3
Martin Dráb Profile Picture

Martin Dráb 64 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans