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

查看:15
本文介绍了客户端对象模型通过 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.

我已检查并且项目存在.我是客户端对象模型的新手.List 对象向我展示了项目数,这很好,我不能只拿 List Item 对象.

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天全站免登陆