c# - 将项目添加到 SharePoint Online 列表 c#
问题描述
我有一个 web api,它的主体中有一些数据,并且我想使用 c# 添加到 SharePoint 在线列表中。但是下面的代码给了我 unauth 错误。
using (var context = new ClientContext(siteUrl))
{
context.ExecutingWebRequest += Context_ExecutingWebRequest; // for oAuth it working in get list dat
Web web = context.Web;
List topicsList = context.Web.Lists.GetByTitle("ListName");
ListItemCreationInformation newTopicInfo = new ListItemCreationInformation();
ListItem oListItem = topicsList.AddItem(newTopicInfo);
oListItem["Title"] = "Test";
oListItem["Column1"] = "Test1";
oListItem.Update();
context.ExecuteQuery();
}
解决方案
上面的代码现在工作得很好,我缺少对我的应用程序的权限。要使用 oAuth,我们必须在 SharePoint 中注册一个加载项,并且要在 sharepoint 中发布数据,我必须将 FullControl 授予我的加载项,但在创建时我已将其设为只读。下面是参考。 参考
推荐阅读
- blockchain - polkadot{.js} 扩展有替代方案吗?如何创建和使用其他钱包?
- wordpress - WC_Widget_Layered_Nav - 指定要使用的全局属性
- node.js - ExpressJS 不在节点中提供我的静态文件
- javascript - Blogger 不接受 HTML
- reactjs - React Material UI TextField 鼠标悬停图标
- react-native - 反应原生;元素类型无效:使用 AdmobBanner 后应为字符串(用于内置组件)
- javascript - 在 localhost 中显示并在 Heroku 中加载但未显示的图像
- css - 如何在 React 中编辑或导入 CSS?
- postman-pre-request-script - 使用 Query Params 的 Postman 预请求脚本登录
- python-3.x - 如何在不拉伸 Tkinter 的情况下调整图像大小?