2

我想使用以下代码更新 SharePoint 文档库中的文件。如下所述: 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

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"
    });
4

3 回答 3

2

在 add 方法中,它给了我错误消息!!!!

所以我发现我应该在更新时使用“方法”而不是“类型”。

于 2014-06-11T13:29:03.960 回答
1

基于 MSDN 文档https://msdn.microsoft.com/en-us/library/office/dn735924.aspx#properties 您必须使用:url、方法、标头、成功和错误

于 2018-07-05T14:45:40.120 回答
1

有同样的问题。改变

body: "Here is the new Body", 

data: "Here is the new Body",

为我解决了这个问题

于 2019-03-28T20:54:35.747 回答