首页 > 解决方案 > 通过 api rest 更新共享点文档的属性

问题描述

通过 api rest 更新共享点文档的属性。 图片 比如我想在文件test.html中编辑test列

标签: apirestsharepointsharepoint-online

解决方案


如果要更新文档名称,请尝试以下示例。

function CreateListItemWithDetails(listName) {
    
    var item = {
        "__metadata": { "type": "SP.Data.Shared_x0020_DocumentsItem" },
        "FileLeafRef": "NBA2.PNG"           
    };

    $.ajax({
        url: _spPageContextInfo.siteAbsoluteUrl + "/_api/web/lists/getbytitle('" + listName + "')/items(9)",
        type: "POST",
        contentType: "application/json;odata=verbose",
        data: JSON.stringify(item),
        headers: {
            "IF-MATCH": "*",
                   "X-HTTP-Method": "PATCH",
                   // Accept header: Specifies the format for response data from the server.
                   "Accept": "application/json;odata=verbose",
                   //Content-Type header: Specifies the format of the data that the client is sending to the server
                   "Content-Type": "application/json;odata=verbose",
                   // X-RequestDigest header: When you send a POST request, it must include the form digest value in X-RequestDigest header
                   "X-RequestDigest": $("#__REQUESTDIGEST").val()
        },
        success: function (data) {
            console.log(data);
        },
        error: function (data) {
            console.log(data);
        }
    });
}

更新: 在此处输入图像描述 在此处输入图像描述


推荐阅读