2

I am trying to create an item in a custom list which only exists in the App I have deployed. I can see the list when I try to access it like this :

MyNotes/Lists/Notes/AllItems.aspx

I can also add Items in the item creation editor in Sharepiont itself. The issue appears when I try to add an item in this list from a Provider Hosted MVC Application. Here is the code :

List notesList = clientContext.Web.Lists.GetByTitle("Notes");

try
{
    clientContext.ExecuteQuery();
}
catch (Exception e)
{
    Console.WriteLine(e);
    throw;
}

ListItemCreationInformation noteCreationInformation = new ListItemCreationInformation();
ListItem newNoteItem = notesList.AddItem(noteCreationInformation);
newNoteItem["NoteTitle"] = model.Titre;
newNoteItem["NoteContent"] = model.Content;
newNoteItem["_Author"] = spUser.UserId;
newNoteItem["_DCDateCreated"] = DateTime.Now;
newNoteItem["StartDate"] = model.StartDate;
newNoteItem["_EndDate"] = model.EndDate;
newNoteItem.Update();

clientContext.Load(newNoteItem);

try
{
    clientContext.ExecuteQuery();
}
catch (Exception e)
{
    Console.WriteLine(e);
    throw;
}

The only error I receive while debugging the application is a NotImplementedException. I am developing on a Dev site on sharepoint Online on Office 365 so I don't have any way to check logs or anything server side.

What Am I doing wrong ?

  • Try removing this line: clientContext.Load(newNoteItem); – Damjan Tomic Jan 31 '17 at 15:40
  • Thanks for your answer. Actually that is something I added after looking through the Internet but with or without, I have the same issue.. – Guigui Jan 31 '17 at 15:42
  • 1
    Ok, np. It looked to me that it might cause the problem. Is there any description of the exception you're getting? – Damjan Tomic Jan 31 '17 at 15:44
  • No unfortunately there are no detail in the exception except the standard message for NotImplementedException IE : This method or operation is not implemented. No Inner Exceptions, No Data. The stacktrace does say that the error come from the ExecuteQuery. If I were on a SharePoint Server on prem that would be easier to debug but SharePoint Online is making this almost impossible to find out what is going on – Guigui Jan 31 '17 at 16:02
  • The other thing that comes to my mind is that it maybe has something to do with the Author field.. Can you try to remove the underscore from this line: newNoteItem["_Author"] = spUser.UserId; and change it to newNoteItem["Author"] = spUser.UserId; – Damjan Tomic Jan 31 '17 at 16:11

Your Answer

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

Browse other questions tagged or ask your own question.