[英]update a file content in SharePoint document library with REST - javascript
I want to update a file in SharePoint document library with the following code. 我想使用以下代码更新SharePoint文档库中的文件。 As descriptions in: http://msdn.microsoft.com/en-us/library/office/dn450841(v=office.15).aspx#bk_FileRequestExamples http://msdn.microsoft.com/en-us/library/office/dn292553(v=office.15).aspx#Files
如以下说明中所述: 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文件#
The executeAsync returns successful but the file isn't update! executeAsync返回成功,但文件未更新! Can anybody help!?
有人可以帮忙吗?
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"
});
In the add method it gives me the error message!!!! 在添加方法中,它给我错误信息!!
So I find out I should use "method" instead of "type" when I update. 所以我发现我在更新时应该使用“方法”而不是“类型”。
基于MSDN文档https://msdn.microsoft.com/zh-cn/library/office/dn735924.aspx#properties,您必须使用:URL,方法,标头,成功和错误
had the same problem. 有同样的问题。 changing
改变
body: "Here is the new Body",
to 至
data: "Here is the new Body",
solved the issue for me 为我解决了这个问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.