// Initialize the RequestExecutor with the app web URL.
executor = new SP.RequestExecutor(appweburl);
alert(appweburl);
alert(appweburl + "/_api/SP.AppContextSite(@target)/web/GetFileByServerRelativeUrl('lib/folder/cool.txt')/$value?@target='" + hostweburl + "'");
executor.executeAsync({
url: appweburl + "/_api/SP.AppContextSite(@target)/web/GetFolderByServerRelativeUrl('lib/folder/cool.txt')/$value?@target='" + hostweburl + "'",
method:"POST",
body:"Updated contents of the file go here",
headers: {
"X-HTTP-Method":"PUT"
},
success: FileSuccessHandler,
error: FoldersErrorHandler
});
}
Hi,
Check if your "*.js" files have been loaded before your REST operation.
Did you try to execute the resquest through you browser ?
Regards.
Gilles Martinez
Twitter
Blog
Please mark as helpful/answer if this resolved your post
GetFileByServerRelativeUrl.... since you're getting a FILE, you'll need a URL to a FILE (not just a library)... by SERVER relative URL, so you'll need to include the site collection path and such, not just the subsite relative URL.
Now working fine....
url: appweburl + "/_api/SP.AppContextSite(@target)/web/ GetFileByServerRelativeUrl('/sites/apps/Shared Documents/test.txt')/CheckOut()?@target='" + hostweburl + "'",
method: "POST",
data: metatdata,
- Marked as answer by GOWTHAM RAJAMANICKAM 3 hours 29 minutes ago