1
Reply

unauthorized when i want to load data from a list of a site

mina ssaaa

mina ssaaa

Sep 28 2016 2:40 AM
319

hello

 i want to load data from a sharepoint site. I also give my username and password but it is said it is unauthorized, below is my code, can you help me pelase?thank you

 
  1.   

    tring siteUrl = "the name of my sharepointsite";

    ClientContext clientContext = new ClientContext(siteUrl);

    clientContext.AuthenticationMode = ClientAuthenticationMode.FormsAuthentication;

    clientContext.FormsAuthenticationLoginInfo = new FormsAuthenticationLoginInfo("myusername", "mypassword");

    List oList = clientContext.Web.Lists.GetByTitle(item.Header);

    CamlQuery query = CamlQuery.CreateAllItemsQuery(100);

    //CamlQuery camlQuery = new CamlQuery();

    // camlQuery.ViewXml = "<View><RowLimit>100</RowLimit></View>";

    ListItemCollection collListItem = oList.GetItems(query);

    clientContext.Load(collListItem);

    clientContext.ExecuteQuery();

    foreach (ListItem oListItem in collListItem)

    {

    mylist.mydynamicgrid.RowDefinitions.Add(new RowDefinition

    {

    Height = new GridLength(1, GridUnitType.Auto),

    Tag = item

    });

    }





 

Answers (1)