sp.web.getFileByserVerrelativerl(fileUrl)不起作用



我正在使用sp.js库的 SP.Web.getFileByServerRelativeUrl(fileurl)函数。我的网站层次结构就像这样

Host Web
  App1 Web
     DocumentLibrary1
  App2 Web

Wher App1 Web是由我的SharePoint 2013 App 1创建的Web,App2 Web是由我的SharePoint 2013 App 2创建的Web。这是我的代码

var ctx = SP.ClientContext.get_current();
var appctx = new SP.AppContextSite(ctx, 'hostweburl/app1');
var file = appctx.get_web().getFileByServerRelativeUrl("/DocumentLibrary1/myfile.xml");
ctx.load(file);
ctx.executeQueryAsync(function () {
    var title = file.get_title();
}, this.onError);

,但我遇到了一个错误"值不在预期范围内"。似乎"/documentLibrary1/myfile.xml"不是文件的服务器相对URL。我还尝试了"/app1/documentlibrary1/myfile.xml",这也无法正常工作。谁可以帮助

put/sites//documentlibrary1/myfile.xml作为getfilebyserverrelativeurl参数

与服务器URL相对URL。

for Eg:" http:///stites/stiteName/list/folder"

在服务器相关URL中给出"站点/siteName/list/文件夹"。

最新更新