Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Update a file content in SharePoint document library with REST - javascript

$
0
0

I want to update a file in SharePoint document library with the following code (in Sharepoint 365). The same as:

http://msdn.microsoft.com/en-us/library/office/dn450841(v=office.15).aspx#bk_FileRequestExampleshttp://msdn.microsoft.com/en-us/library/office/dn292553(v=office.15).aspx#Files

The executeAsync returns success but the file isn't update! 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"
    });




Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>