1

Trying to create a list item in the SharePoint list in a batch of 5 using Visual Studio but the clientContext.ExecuteQuery() throws exception and only create 1 list item.

var url = "calling a webservice";
var content = syncClient.DownloadString(url);
JsonResultInfo jsri = new JsonResultInfo();
List<JsonResult> dynJson = JsonConvert.DeserializeObject<List<JsonResult>>(content);

//Connect to SharePoint and read Idea list

  • List item

    CamlQuery query = new CamlQuery(); string siteUrl = "sharepoint site list url"; ClientContext clientContext = new ClientContext(siteUrl); SP.List oList = clientContext.Web.Lists.GetByTitle("LIST NAME"); ListItemCollection listItems = oList.GetItems(query); clientContext.RequestTimeout = -1; clientContext.Load(listItems); clientContext.ExecuteQuery();| oListItem["title] = item.title; oListItem["body"] = item.body; oListItem.Update(); itemCount++;

get itemcount to 5 , then

clientContext.ExecuteQuery(); // the execption is thrown saying A first chance exception of type 'Microsoft.SharePoint.Client.ServerException' occurred in

Microsoft.SharePoint.Client.Runtime.dll

ps: Added Request timeout , and gave this exception

1

Please increase RequestTimeOut of ClientContext as shown below:

clientContext.RequestTimeout = -1;

Hope it works for you.

  • Hi, i added it. it thrw another error "A first chance exception of type 'Microsoft.SharePoint.Client.ServerException' occurred in Microsoft.SharePoint.Client.Runtime.dll ". i have modified the question. kindly help! – Unnati Joshi May 12 '17 at 12:47
  • Didn't understood please elaborate more in details – Samir Khimani May 12 '17 at 12:50
  • You will need to put clientContext.ExecuteQuery(); after each item update.because SharePoint didn't understood currently which item going to update. – Samir Khimani May 12 '17 at 12:55
  • i am pulling the data from a web service and comparing the data present in the share point and which ever data that is not present in share point list , is added to the list as a new item. – Unnati Joshi May 12 '17 at 12:55
  • still throwing Microsoft.SharePoint.Client.ServerException – Unnati Joshi May 16 '17 at 6:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.