【问题标题】:Adding item to a sharepoint list using rest api使用rest api将项目添加到共享点列表
【发布时间】:2016-11-28 09:37:10
【问题描述】:

我有一个包含列命名的列表 - Column1、Column2、Column3..等。 使用 rest api 将项目添加到列表中。 可以使用循环设置这些字段的数据吗? ?它需要根据用户的数字动态设置 - 所以需要一个循环。代码将如何..

我当前的代码如下:

$.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.');
    }
 });

【问题讨论】:

    标签: jquery rest sharepoint-2013


    【解决方案1】:

    谢谢大家。但我能够解决这个问题。 创建了一个对象 - 创建属性并动态设置其值,并将此对象传递给函数。

    【讨论】:

      猜你喜欢
      • 2013-05-06
      • 2015-12-20
      • 1970-01-01
      • 2015-01-23
      • 1970-01-01
      • 1970-01-01
      • 2011-06-13
      • 2012-01-05
      • 1970-01-01
      相关资源
      最近更新 更多