0

I'm trying to retrieve an item from a list, just for demo purposes. But, when I try to do that, I'm getting a ServerException on the ExecuteQuery().

This is the exception:

An exception of type 'Microsoft.SharePoint.Client.ServerException' occurred in Microsoft.SharePoint.Client.Runtime.dll but was not handled in user code

Additional information: Item does not exist. It may have been deleted by another user.

And this is the code:

clientContext.Load(clientContext.Web.CurrentUser);
var lists = clientContext.Web.Lists;
clientContext.Load(lists);

var spList = lists.GetById(Guid.Parse(SPListId));
clientContext.Load(spList);

var spListItem = spList.GetItemById(7);
clientContext.Load(spListItem);

clientContext.ExecuteQuery();

I've narrowed the problem down to the GetItemId(SPListItemId) method. I'm quite sure that there is an item with the given SPListItemId, cause when I open the properties of the specified file, I see that the ID parameter is 7.

Does anyone know what is happening?

Thanks a lot!

  • Did you also make sure that the SPListId used in code and the list you checked are the same? – Unnie Oct 4 '16 at 15:00
  • I can verify that. The ID is the same as listed in the "Library Settings" url. – koelkastfilosoof Oct 4 '16 at 15:04
0

I've figured out what the issue was. For those coming by later, here's what I did.

The problem was due to a lack of permissions in my Add-In. The Add-In needs minimal permissions to "List" "Read" in your App Manifest. Hope this helps.

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.