通过 api rest 更新共享点文档的属性
Update the properties of a sharepoint document via api rest
通过 api rest 更新共享点文档的属性。
Image
例如,我想在文档 test.html 中编辑列 test
如果要更新文档名称,请尝试以下示例。
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);
}
});
}
更新:
通过 api rest 更新共享点文档的属性。 Image 例如,我想在文档 test.html 中编辑列 test
如果要更新文档名称,请尝试以下示例。
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);
}
});
}
更新: