0
我有一个列名称列名称 - Column1,Column2,Column3..etc。 使用rest api将项添加到列表中。 可以使用循环设置这些字段的数据。 ?它需要根据来自用户的数字动态设置,因此需要一个循环。该代码是如何被..使用rest api将项目添加到SharePoint列表
我当前的代码如下:
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl +"/_api/Web/Lists/GetByTitle(listname)/Items",
type: "POST",
headers: {
"accept": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"content-Type": "application/json;odata=verbose"
},
data: __metadata: { 'type': 'SP.Data.customlistListItem' },
Title: 'title',
Column1:'value1',
Column2:'value2',
Column3:'value3',
Column4:'value4',
Column5:'value5',
success: function (data) {
//console.log(data);
alert('added');
},
error: function (error) {
//alert(JSON.stringify(error));
alert('Some error occured. Please try again later.');
}
});