Is there any option to execute CSOM code from .net core application? I have a bot solution from this i need to store all the conversation details in SharePoint list. When executing the code, i am getting 400 bad request error. How to resolve this? This is SharePoint online. My code will be published in Azure environment.

My code,

            using (var ctx = new ClientContext(siteUrl))
                ctx.Credentials = new SharePointOnlineCredentials(userName, password);
                Web web = ctx.Web;
                ctx.Load(web, w => w.Title);
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("Able to access Your site. Title - " + ctx.Web.Title);
        catch (Exception ex)
            Console.WriteLine("Unable to access your site. Please find the error below.");

Getting "Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException: The property or field 'Title' has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested." error.

  • I guess it wont work in .net Core
    – Gaurravs
    Aug 6, 2019 at 12:53
  • storing bot conversations in a SharePoint list is going to give you scaling issues very quickly. I'd use a cosmos db or Azure table storage if I were you Aug 6, 2019 at 12:53
  • aexecutequeryasync() => wait() May 17, 2020 at 7:33

2 Answers 2


We can install the package as below.

Install-Package TTCUE.NetCore.SharepointOnline.CSOM.16.1.8029.1200 -Version 16.1.8029.1200

More information is here: TTCUE.NetCore.SharepointOnline.CSOM.16.1.8029.1200

Or use the following solution from GitHub: NetCore.CSOM

Or follow the steps below.

1.Create a .NET Core console app.

2.Add the references: Microsoft.SharePoint.Client.Portable.dll, Microsoft.SharePoint.Client.Runtime.Portable.dll, and Microsoft.SharePoint.Client.Runtime.Windows.dll.

Note: If the project has references to Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll, please remove them.

These references can be accessed by installing CSOM library into another project, and then navigating to installed nuget packages in the file directory: c:\Users\user\.nuget\packages\microsoft.sharepointonline.csom\(version)\lib\netcore45

3.Add the code below to the .NET Core 2.0 console application:

namespace ConsoleApp1 {
    class Program {
        static void Main(string[] args) {
            string targetSiteURL = @"https://xxx.sharepoint.com/sites/xxx";

            var login = "[email protected]";
            var password = "xxx";

            SharePointOnlineCredentials onlineCredentials = new SharePointOnlineCredentials(login, password);

            ClientContext ctx = new ClientContext(targetSiteURL);

            ctx.Credentials = onlineCredentials;

            Web web = ctx.Web;
            ctx.Load(web, w => w.Title);
            Console.WriteLine("Web title:" + web.Title);
  • I have added it and now i am not receiving error when executing the query. But still i am getting error. Added code and error message in question. Aug 7, 2019 at 6:16

MS has released new version few days back with .net standard version. https://developer.microsoft.com/en-us/microsoft-365/blogs/net-standard-version-of-sharepoint-online-csom-apis/

Hope we can create React (which is Microsoft promoting these days with SPFx) easily. So all type of SharePoint applications can work under React roof.

This only supports SP online. No support for SP-onprem

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.