Forum Discussion

tejaswini1010's avatar
tejaswini1010
Copper Contributor
Dec 22, 2019

How to solve feild and property not initialized exception in c#.net when retriving sharepoint list

Hi ,

i got exception fieldorproperty not initialized  while creating client context variable when fetching sharepoint list data in c#.net project

following is  code 

const string siteurl = "https://indica.sharepoint.com/sites/DemoBot/Lists";
string login = "teb@ind.onmicrosoft.com";
string password = "abcsd";
const string listname = "ListDemoBot";
string result = string.Empty;
var securepassword = new SecureString();

try
{
foreach (var c in password)
{
securepassword.AppendChar(c);

}

var credential = new sp.SharePointOnlineCredentials(login, securepassword);
sp.ClientContext clientcontext = new sp.ClientContext(siteurl);
clientcontext.Credentials = credential;
sp.List olist = clientcontext.Web.Lists.GetByTitle(listname);
sp.CamlQuery calmquery = new sp.CamlQuery();
var username = "Test1";
calmquery.ViewXml = $"<View><Query><Where>" + $"<Eq><FieldRef Name='Title'/>< Value Type = 'Text' >{username}</ Value > </ Eq > " + $"</Where></Query><RowLimit>1</RowLimit></View>";
sp.ListItemCollection collistItem = olist.GetItems(calmquery);
clientcontext.Load(collistItem);
clientcontext.ExecuteQuery();

}

catch
{
throw;
}

  • c03945's avatar
    c03945
    Copper Contributor

    Disculpá, pero me podrías orientar como puedo comenzar a programar para SharePoint Online?
    Busco por internet pero encuentro todo para onpremise.
    Gracias

Resources