I want to update a file in SharePoint document library with the following code. 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
The executeAsync returns successful 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"
});
In the add method it gives me the error message!!!!
So I find out I should use "method" instead of "type" when I update.