Working with RESTful API Ingeniux CMS Web Services API

Below is a step by step example on how to work with Ingeniux CMS Web Services API.

Please note that by default, Cross Origin Resource Sharing (CORS) is not enabled on Ingeniux CMS RESTful Services. So working with RESTful API with client side javascript across domain will not work.

To enable CORS, make sure to add the following configuration as child element of "CMSSettingsGroup/CMSContentStoreSettings" in web.config, and add the entries to the domains that are allowed to access RESTful API:

                      <
                      allowedOriginsForRESTAPIVisit
                      >
  <CORSEntry origin="http://anothersite1.com" />
  <CORSEntry origin="http://anothersite2.com:8080" />
</allowedOriginsForRESTAPIVisit>
Preparation

We are using JQuery for the example, so reference JQuery in your page:

                    <
                    script type="text/javascript" src="/Scripts/jquery-1.8.2.js"></script>
JQuery Example

Example below perform the show how to perform an API called right after logging in.

In your actual integration project, you are do the API call anytime, after the login successful and token received:

JavaScript
$.ajax({
    url: "http://[your site address]/REST/MembershipProvidersServices.svc/Login",
    type: "POST",
    crossDomain: true,
    data: JSON.stringify({ 
        "userName": "[username]", 
        "password": "[password]", 
        "membershipProviderName": "[membership provider name]" }),
    dataType: "json",
    contentType: "application/json",
    success: function (response) {
        var token = response.message;

        //perform actual operation after login successful, in this case we are getting page data
        $.ajax({
            url: "http://[your site address]/REST/PageCommandsServices.svc/GetPageData",
            type: "POST", //all RESTful API uses POST method
            crossDomain: true, //make sure to set cross domain being true is hit from another domain
            headers: {
                "X-IGXAToken": token //send security token as header
            },
            data: JSON.stringify({ 
                "id": "x97", 
                "pubTarget": 
                "Staging" }),
            dataType: "json",
            contentType: "application/json",
            success: function (response2) {
                alert(JSON.stringify(response2));
                //do something
            },
            error: function (xhr, status) {
                alert("error");
            }
        });
    },
    error: function (xhr, status) {
        alert("error");
    }
});
See Also

Other Resources