我正在进行基本的 OData/REST 调用来访问 SP2013 文档库。 我正在尝试获得项目的 URL,但无法确定如何做到这一点。 我非常熟悉服务器端对象模型,并且了解文件对象比项目深一个级别。 有人可以指导我正确的方向或分享有关如何进入文件级别的文档吗? 我已经在谷歌上进行了搜索。 这是适用于仅获取访问文档库中所有项目和任何元数据列的代码:
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
</html>
<script>
// workaround for access error
jQuery.support.cors = true;
// create REST query
var requestUri = "http://sp2013/_api/Web/Lists/getByTitle('Documents')/items";
// execute AJAX request
$.ajax({
url: requestUri,
type: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: function(data){
alert(data.d.results);
$.each(data.d.results, function(index, item){
if (item["Meta1"] == null) {
$("body").append("<h1>No Title</h1>");
}
else {
$("body").append("<h1>" + item["Meta1"] + "</h1>");
}
});
},
error: function(jqXHR, textStatus, errorThrown){
alert(textStatus);
}
});
</script>