Making a REST AJAX call from Basic Page The following successfully calls a REST Services Module endpoint when contained in a module but I cannot get it to work within the script tags of a basic page.

(function ($) {

  var myapi = {
    'apiPath': '/api/award'
  };

  // REST functions.
  myapi.create = function (award) {
    $.ajax({
      type: 'POST',
      url: 'http://localhost/testsite/api/award',
      data: JSON.stringify(award),
      dataType: 'json',
      contentType: 'application/json'
    });
  };

  myapi.create({ award : 'The Award' });

}(jQuery));


I am wondering if it is even possible to embed AJAX calls in a Basic Page.

Thanks for any help,

Orville
It turned out to be a 401 error that only occurred when the user was not logged in. Changing the 'access arguments' string in the hook_services_resources array fixed the problem.