[英]update a file content in SharePoint document library with REST - javascript
我想使用以下代碼更新SharePoint文檔庫中的文件。 如以下說明中所述: http : //msdn.microsoft.com/zh-cn/library/office/dn450841( v = office.15) .aspx# bk_FileRequestExamples http://msdn.microsoft.com/zh-cn/library/辦公室/ dn292553(v = office.15)的.aspx文件#
executeAsync返回成功,但文件未更新! 有人可以幫忙嗎?
var spUrl = appWebUrl + "/_api/SP.AppContextSite(@target)/web/GetFileByServerRelativeUrl('" + itemUrl + "')/$value?@target='" + hostWebUrl + "'";
var executor = new SP.RequestExecutor(appWebUrl);
executor.executeAsync(
{
url: spUrl,
type: "POST",
body: "Here is the new Body",
headers: {
"X-HTTP-Method": "PUT",
"X-RequestDigest": $("#__REQUESTDIGEST").val()
},
success: readContents,
error: errorHandler,
state: "Update"
});
在添加方法中,它給我錯誤信息!!
所以我發現我在更新時應該使用“方法”而不是“類型”。
基於MSDN文檔https://msdn.microsoft.com/zh-cn/library/office/dn735924.aspx#properties,您必須使用:URL,方法,標頭,成功和錯誤
有同樣的問題。 改變
body: "Here is the new Body",
至
data: "Here is the new Body",
為我解決了這個問題
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.