none
Client Object Model - The remote server returned an error: (403) Forbidden. RRS feed

  • 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

    Thursday, June 19, 2014 4:44 PM

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,

    Jason

    Jason 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
    Friday, June 20, 2014 8:00 AM

All replies

  • This would indicate you either do not have permissions to the site, or the list.

    Brandon Atkinson
    Blog: http://sharepointbrandon.com

    Thursday, June 19, 2014 6:49 PM
  • 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,

    Jason

    Jason 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
    Friday, June 20, 2014 8:00 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

    Bijay Kumar MVP

    Tuesday, March 26, 2019 7:04 AM
  • Is it plausible that you are experiencing the error "HTTP 403 Forbidden" in SharePoint when trying to run the code? Do you have the proper credentials? If not, were they inadvertently blacklisted?
    Tuesday, April 16, 2019 3:54 AM