Resolved WebException in Microsoft.Sharepoint.Client.Runtime.dll

gsaunders

Member
Joined
Mar 30, 2021
Messages
16
Programming Experience
5-10
Target .NET5.0, Windows Forms App template

Environment:
  • Windows 10
  • Visual Studio 2019 16.9.3
Goal:
  • Connect to our Online Sharepoint site through our Office 365 E5.
  • Then be able to read settings, upload documents to site / library and set metadata.
Code Setup:
  • We have added Microsoft.SharePoint.Online.CSOM (16.1.2111.12000) Nuget Package
  • We have added Microsoft .Identity.Client (4.29.0) Nuget Package
Code:

For the using section we have these added.
C#:
using Microsoft.SharePoint.Client;
using Microsoft.Identity.Client;
using System.Threading.Tasks;

We have the following code to authenticate, make connection, load web and try to view settings:
C#:
        public static async Task CSOMAuthenticate(string[] args)
        {
            string siteURL = "https://ourname.sharepoint.com/sites/sitename";
            string clientId = "ourclientid"; // Get client ID from Azure AD
            string secrete = "ourclientsecret";// Get Client Secrete from Azure AD
            string tenantId = "ourtenantID";

            //For SharePoint app only auth, the scope will be the SharePoint tenant name followed by /.default
            var scopes = new string[] { "https://ourname.sharepoint.com/.default" };

            var accessToken = await GetApplicationAuthenticatedClientAccessToken(clientId, secrete, scopes, tenantId);
            var clientContext = GetClientContextWithAccessToken(siteURL, accessToken);
            Web web = clientContext.Web;
            clientContext.Load(web);
            MessageBox.Show("test", "Title");

            clientContext.ExecuteQuery();

            MessageBox.Show(web.Title, "Title");

        }

        internal static async Task<string> GetApplicationAuthenticatedClientAccessToken(string clientId, string secrete, string[] scopes, string tenantId)
        {
            IConfidentialClientApplication clientApp = ConfidentialClientApplicationBuilder
                                            .Create(clientId)
                                            .WithClientSecret(secrete)
                                            .WithTenantId(tenantId)
                                            .Build();

            AuthenticationResult authResult = await clientApp.AcquireTokenForClient(scopes).ExecuteAsync();
            string accessToken = authResult.AccessToken;
            return accessToken;
        }
        public static ClientContext GetClientContextWithAccessToken(string targetUrl, string accessToken)
        {
            ClientContext clientContext = new ClientContext(targetUrl);
            clientContext.ExecutingWebRequest +=
                delegate (object oSender, WebRequestEventArgs webRequestEventArgs)
                {
                    webRequestEventArgs.WebRequestExecutor.RequestHeaders["Authorization"] =
                        "Bearer " + accessToken;
                };
            return clientContext;
        }

In the above code I know the tenantid, secret and clientID are correct as I am getting back an accessToken. If I change any of those values I get error and no accessToken. So I feel like I have it all configured correctly.

The ExecuteQuery() seems to be where we end up with the error:
System.Net.WebException in Microsoft.Sharepoint.Client.Runtime.dll

When debugging (stepping through) and trying to examine the clientContext or Web I see the following (before the ExecuteQuery):

1617290173300.png


1617290242590.png


Above you see all of these "thew an exception" statements, but I don't know if that is really an issue, because there are no values yet or if that is indicating an actual issue., but at the end of it all you see this:

'DocVaultTransfer.exe' (CoreCLR: DefaultDomain): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Private.CoreLib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\VS2019\Repo\DocVaultTransfer\bin\Debug\net5.0-windows\DocVaultTransfer.dll'. Symbols loaded.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\5.0.4\System.Windows.Forms.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\5.0.4\System.Windows.Forms.Primitives.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.ComponentModel.Primitives.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Runtime.InteropServices.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Drawing.Primitives.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Collections.Specialized.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\5.0.4\System.Drawing.Common.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Threading.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Diagnostics.TraceSource.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Collections.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\Microsoft.Win32.Primitives.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.ComponentModel.EventBasedAsync.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Threading.Thread.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\5.0.4\Accessibility.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Runtime.Extensions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.ComponentModel.TypeConverter.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.ComponentModel.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\5.0.4\Microsoft.Win32.SystemEvents.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Buffers.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Collections.NonGeneric.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Memory.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Runtime.CompilerServices.Unsafe.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\VS2019\Repo\DocVaultTransfer\bin\Debug\net5.0-windows\Microsoft.SharePoint.Client.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\VS2019\Repo\DocVaultTransfer\bin\Debug\net5.0-windows\Microsoft.SharePoint.Client.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\netstandard.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Linq.Expressions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Console.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\VS2019\Repo\DocVaultTransfer\bin\Debug\net5.0-windows\Microsoft.Identity.Client.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Private.Uri.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Security.Cryptography.X509Certificates.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Security.Cryptography.Primitives.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Linq.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Diagnostics.Tracing.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Collections.Concurrent.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Threading.Tasks.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Text.RegularExpressions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.ObjectModel.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Runtime.InteropServices.RuntimeInformation.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Net.Http.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Net.Primitives.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Diagnostics.DiagnosticSource.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Net.Security.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Net.Sockets.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Net.NameResolution.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Threading.Overlapped.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Threading.ThreadPool.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Security.Principal.Windows.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Security.Claims.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Security.Cryptography.Encoding.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Runtime.Serialization.Formatters.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Runtime.Numerics.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Runtime.Serialization.Primitives.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Data.Common.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Xml.ReaderWriter.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Private.Xml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\Remote Debugger\x64\Runtime\Microsoft.VisualStudio.Debugger.Runtime.NetCoreApp.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The thread 0x309c has exited with code 0 (0x0).
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Net.WebHeaderCollection.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Resources.ResourceManager.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Text.Encoding.Extensions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Net.Requests.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'DocVaultTransfer.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Net.ServicePoint.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Exception thrown: 'System.Net.WebException' in Microsoft.SharePoint.Client.Runtime.dll

As an FYI here is how Azure is configured:
1617291005481.png

1617291011883.png

1617291018509.png


So at this point I am not sure why we are getting the error we are getting or how to debug it. New area for me.

I am following every possible site I can that gives detail about this and essentially doing what they have all said to do... I think!

So I may have to go back to older .NET framework or look at using different methodology to do this. What I have here seemed the simplest, but may have to get into REST based or other, but hoped to avoid that.

Thanks in advance
 
Last edited by a moderator:
Solution
Thanks for reply... I knew going doin the newer .NET Standard may be trial and error.

So I have finally gotten it to work using ClientID with Certificate INSTEAD of ClientID and Secret. This link clued me into the secret not being the path to go, but the certificate:
Working with Application Permissions (App-Only Auth) in SharePoint Online and the Microsoft Graph

So I followed this link on creating the certificate:
Granting access via Azure AD App-Only

And then installed the certificate to my local computer cert store.

And finally used the code from this site to achieve an initial connection that read me back the data I expected:
Using .NET Standard CSOM and MSAL.NET for App-Only auth in SharePoint Online

I...
So I think I have found that client + secret will not work, but I need client + certificate.

I have been through so many sites I am starting to think I am getting many bits of truth, but not all in one spot.

I will build out the certificate side and see if that resolves what I am seeing.
 
Sorry, I don't know. I've only ever used the CSOM using .NET Framework 4.8, not .NET 5.0. Also I just use the regular ClientContext passing in SharePointOnlineCredentials like:
C#:
ctx.Credentials = new SharePointOnlineCredentials("account@mydomain.com", password);

Welcome to the pain joy of SharePoint where there the best documentation is wisdom on the Internet rather than in books or MSDN. When I interviewing for this current job, I said "I hate SharePoint". The interview suddenly stopped and the panel said, "You're hired." Little did I know that the job description that said 80% .NET programming and 10% SharePoint development, and 10% SharePoint admin would later evolve into 10% .NET programming, and 90% everything SharePoint.
 
Thanks for reply... I knew going doin the newer .NET Standard may be trial and error.

So I have finally gotten it to work using ClientID with Certificate INSTEAD of ClientID and Secret. This link clued me into the secret not being the path to go, but the certificate:
Working with Application Permissions (App-Only Auth) in SharePoint Online and the Microsoft Graph

So I followed this link on creating the certificate:
Granting access via Azure AD App-Only

And then installed the certificate to my local computer cert store.

And finally used the code from this site to achieve an initial connection that read me back the data I expected:
Using .NET Standard CSOM and MSAL.NET for App-Only auth in SharePoint Online

I installed my certificate to local computer vs current user so I changed the line for new X509Store to use the correct location.

Now... that it only took 2 days to figure this out I now need to see if I can start actually uploading documents and metadata from another system and database to sharepoint.

Yes the pain joy is real! LOL
 
Solution
I have your error, before I call the Context, I have your error, can you explain me how do you fix

public void UploadFileToSPO(string strPPTName, ref string strTargetUrl)
{
try
{
string siteTarget = ConfigurationManager.AppSettings["SharePointSite"].ToString();
using (var context = new ClientContext(siteTarget)) // the error appear here
{

string u = ConfigurationManager.AppSettings["SP_QMSFR_Online_Usr"].ToString();
string p = ConfigurationManager.AppSettings["SP_QMSFR_Online_Psw"].ToString();
 

Latest posts

Back
Top Bottom