【问题标题】:update a file content in SharePoint document library with REST - javascript使用 REST 更新 SharePoint 文档库中的文件内容 - javascript
【发布时间】:2014-06-10 20:46:55
【问题描述】:

我想使用以下代码更新 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"
    });

【问题讨论】:

    标签: javascript rest sharepoint sharepoint-2013 sharepointdocumentlibrary


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        【解决方案3】:

        有同样的问题。改变

        body: "Here is the new Body", 
        

        data: "Here is the new Body",
        

        帮我解决了问题

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2020-09-07
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多