Forum Discussion
amir asyraf
Aug 18, 2017Copper Contributor
CSOM : Server Unauthorized Access Exception: Access Denied.
i created window agent for the end user. where the data will send to the Data list Sharepoint. The problem is, when i try to use to the window agent to the local company user account, it shown the pr...
- Aug 18, 2017
My suggestion, you're using SharePoint On-Premises.
For On-Premises credentials should be defined in the following way:
using System.Net; using Microsoft.SharePoint.Client; using (ClientContext context = new ClientContext("http://sp-onprem/")) { context.Credentials = new NetworkCredential("user", "password", "domain"); // CSOM code }
SharePoint Online requires the secure string as a password:
using (ClientContext context = new ClientContext("https://contoso.sharepoint.com/")) { string pwd = "password"; SecureString password = new SecureString(); foreach (char c in pwd.ToCharArray()) { password.AppendChar(c); } context.Credentials = new SharePointOnlineCredentials("user", password); // CSOM code }
Also, I would recommend to figure out what auth scenario your instance is configured to support.
Deleted
Aug 18, 2017Hi it is because you do not use the credentials in your clientcontext...
please take a look here http://www.c-sharpcorner.com/blogs/office365-how-to-connect-sharepoint-online-site-using-csom
- amir asyrafAug 18, 2017Copper Contributor
sorry mate, but the issue still same.
- DeletedAug 18, 2017
First check if you are connected. then if connected try this : http://www.c-sharpcorner.com/code/2635/create-a-list-item-in-sharepoint-2013-using-csom-in-visual-studio.aspx