Sharepoint Rest API - 更新页面内列表的列

Sharepoint Rest API - Updating a column of a list inside a Page

我在 SitePages 中有一个包含列表的页面。我可以使用 (GET) /_api/web/lists/getbytitle('Site Pages')/items(29)

访问页面

但是,在上面的 GET 响应中,列表没有显示,我如何访问页面内的列表?

我还需要更新该列表中所有行的列值,这可能吗?

提前致谢! 塞尔吉奥

你可以获取页面内的列表,直接使用List Title with Rest API 像这样:

/_api/web/lists/getbytitle('ListTitleInsidePage')/项目

因为 /_api/web/lists/getbytitle('Site Pages')/items(29) 将 return 站点页面的元数据列,而不是页面内的列表。

而如果要更新页面内的list列,还是直接使用页面内的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。