我尝试使用Sitecore RESTful API通过Javascript检索项目子项。我在这里遵循文档: https://doc.sitecore.net/sitecore_experience_platform/developing/developing_with_sitecore/sitecoreservicesclient/the_restful_api_for_the_itemservice
我使用以下Javascript函数:
function loadChildren(id, parentNode) {
var xhr = new XMLHttpRequest();
xhr.open("GET", window.location.protocol + "//" + window.location.hostname + "/sitecore/api/ssc/item/" + id + "/children");
xhr.onreadystatechange = function () {
if (this.readyState == 4) {
console.log(this.responseText);
var innerHtml = "<ul>"
innerHtml += "</ul>";
$(parentNode).append(innerHtml);
}
};
xhr.send(null);
}
但GET请求返回未找到的&#34;页面#34; HTML。我需要安装一些东西吗?我使用的是Sitecore 7.1
答案 0 :(得分:0)
原来我必须在我的配置中启用Sitecore Item API(Sitecore.ItemWebApi.config):
<patch:attribute name="itemwebapi.mode">StandardSecurity</patch:attribute>
<patch:attribute name="itemwebapi.access">ReadOnly</patch:attribute>
<patch:attribute name="itemwebapi.allowanonymousaccess">false</patch:attribute>