sharepoint - Sharepoint Rest API - 更新页面内列表的列
问题描述
我在 SitePages 中有一个包含列表的页面。我可以使用 (GET) /_api/web/lists/getbytitle('Site Pages')/items(29) 访问该页面
但是,在上面的 GET 响应中,列表没有显示,我如何访问页面内的列表?
我还需要更新该列表中所有行的列值,这可能吗?
提前致谢!塞尔吉奥
解决方案
您可以获取页面内的列表,直接使用带有 Rest API 的列表标题,如下所示:
/_api/web/lists/getbytitle('ListTitleInsidePage')/items
因为 /_api/web/lists/getbytitle('Site Pages')/items(29) 将返回站点页面的元数据列,但不返回页面内的列表。
而如果要更新页面内的列表列,还是直接使用页面内的ListTitle:
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('List Name Inside Page')/items(Your record ID)",
type: "POST",
headers: {
"accept": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"content-Type": "application/json;odata=verbose",
"IF-MATCH": "*",
"X-HTTP-Method": "MERGE"
},
data: "{__metadata:{'type':'SP.Data.YourlistnameListItem'},Title:"
Ur new input "}",
/*where Title is column name and add your desired new data*/
success: function(data) {
console.log(data.d.results);
},
error: function(error) {
alert(JSON.stringify(error));
}
});
并且如果需要更新所有行,请替换为上面请求中的item Id,使用Rest API一次更新所有行是不可用的。
推荐阅读
- android - 改造 - 非空主体上的 onFailure,空主体上的 onResponse
- python - 我可以通过 Datadog REST API 提取 Datadog 指标信息吗?
- session - 为什么在 Appium 中启动新会话时显示错误
- python - 如何在 Python 中运行时中断函数
- python - 是否可以在我的可导入包中隐藏代码?
- cxf - Websphere liberty 19.0.0.9 找不到 PolicyDataEngineImpl 的构造函数
- c# - 使用 csom c# 在 sharepoint 中更新“创建者”
- sql - SQL:在sql server中的where条件下使用year函数和查询两个日期之间的性能有什么区别
- python - 如何使用 python O365 库获取 Outlook 日历可用时间以使用 aws lex -aws lambda 函数安排约会?
- node.js - 使用自定义错误处理程序时,有没有办法使用 Mocha 测试 ExpressJS 中的错误处理?