Answered by:
Client Object Model - The remote server returned an error: (403) Forbidden.

Question
-
Hello,
- I write the following code in console application to read data from list by client object Model :
ClientContext context = new ClientContext("servername/sites/Dhofar/en-us");
List list = context.Web.Lists.GetByTitle("MenuList");
context.Load(list);
context.ExecuteQuery();
Console.WriteLine(list.Title);
Console.ReadKey(false);- I got an exception "The remote server returned an error: (403) Forbidden." on line "context.ExecuteQuery()"
- I run the console application the same server that has a SharePoint.
How Can I solve this problem?
ASk
Answers
-
Hi,
According to your post, my understanding is that you got forbidden error when retrieve data using client object model.
Per the error, the issue may be related to the permission issue, you can check with the following steps.
First, you can check the permission in the site or list, or use the admin account to check whether it works.
Second, you can use the a credential to check whether it works as below.
ClientContext context = new ClientContext(siteURL); //specific user NetworkCredential credentials = new NetworkCredential("Username", "Passworkd", "Domain"); context.Credentials = credentials; List list = context.Web.Lists.GetByTitle("List1"); context.Load(list); context.ExecuteQuery();
Thanks & Regards,
JasonJason Guo
TechNet Community Support- Proposed as answer by Jaydeep Mungalpara Monday, June 23, 2014 5:47 AM
- Marked as answer by Lindali Sunday, June 29, 2014 8:37 AM
All replies
-
This would indicate you either do not have permissions to the site, or the list.
Brandon Atkinson
Blog: http://sharepointbrandon.com -
Hi,
According to your post, my understanding is that you got forbidden error when retrieve data using client object model.
Per the error, the issue may be related to the permission issue, you can check with the following steps.
First, you can check the permission in the site or list, or use the admin account to check whether it works.
Second, you can use the a credential to check whether it works as below.
ClientContext context = new ClientContext(siteURL); //specific user NetworkCredential credentials = new NetworkCredential("Username", "Passworkd", "Domain"); context.Credentials = credentials; List list = context.Web.Lists.GetByTitle("List1"); context.Load(list); context.ExecuteQuery();
Thanks & Regards,
JasonJason Guo
TechNet Community Support- Proposed as answer by Jaydeep Mungalpara Monday, June 23, 2014 5:47 AM
- Marked as answer by Lindali Sunday, June 29, 2014 8:37 AM
-
Recently I got this error while connecting to SharePoint Online as well as SharePoint 2016 site. So I wrote a detailed blog post. You can follow the blog, maybe it will be helpful.
the remote server returned an error (403) forbidden SharePoint client object model
Many Thanks,
Bijay Kumar
EnjoySharePoint.com | SharePointSky.com | TSInfoTechnologies.com
-