Sitecore RESTful api returning 404 (Javascript, Sitecore 7.1)

649 views Asked by At

I'm trying to use the Sitecore RESTful API to retrieve item children via Javascript. I'm following the documentation here: https://doc.sitecore.net/sitecore_experience_platform/developing/developing_with_sitecore/sitecoreservicesclient/the_restful_api_for_the_itemservice

I'm using the following Javascript function:

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);
}

But the GET request is returning the "page not found" HTML. Do I need to install something for this to work? I'm using Sitecore 7.1

1

There are 1 answers

0
Erica Stockwell-Alpert On

Turns out I had to enable the Sitecore Item API in my config (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>