客户端对象模型通过ID错误获取项目-“项目不存在.它可能已被另一个用户删除" [英] Client object model get item by id error- "Item does not exist. It may have been deleted by another user"

查看:116
本文介绍了客户端对象模型通过ID错误获取项目-“项目不存在.它可能已被另一个用户删除"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试按ID执行获取列表项时出现错误

I am getting error while I try execute get list item by id

 ClientContext clientContext = TokenHelper.GetClientContextWithAccessToken(sharepointUrl.ToString(), accessToken);
        Web web = clientContext.Web;
        clientContext.Load(web);
        clientContext.ExecuteQuery();        
        clientContext.Load(web.CurrentUser);
        clientContext.ExecuteQuery();
        currentUser = clientContext.Web.CurrentUser.Title;
        List _list = web.Lists.GetById(_ListGuid);
        clientContext.Load(_list);
        clientContext.ExecuteQuery();
        Microsoft.SharePoint.Client.ListItem _item = _list.GetItemById(ItemID);
        clientContext.Load(_item);
        clientContext.ExecuteQuery(); //ERROR HERE
        Response.Write(_item["Author"].ToString());

错误:

该项目不存在.它可能已被其他用户删除.

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

我已经检查并且项目存在.我是客户端对象模型的新手.列表对象向我显示了项目计数及其良好状态,我不能仅仅接受列表项目对象.

I have checked and item exist. I am new at client object model. List object show me item count and its fine, I can't just take List Item object.

我知道这很简单,但是我仍然花了很多时间在这简单的事情上.

I know this is something very simple but still I spent so much time at this simply thing.

推荐答案

问题出在清单文件中,并且在部署应用程序时,SharePoint向您询问信任",然后您必须选择列表您要对其进行操作的.

The problem was in the permission in the manifest file, and while you are deploying the app, SharePoint asks you about "trust" then you have to choose the list which you want to operate with.

这篇关于客户端对象模型通过ID错误获取项目-“项目不存在.它可能已被另一个用户删除"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆