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) {
      type: 'POST',
      url: 'http://localhost/testsite/api/award',
      data: JSON.stringify(award),
      dataType: 'json',
      contentType: 'application/json'

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


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

Thanks for any help,


  • What input format do you use? how that input format configured? – Mohammad Ali Akbari Oct 30 '12 at 18:02
  • Is there any errors in error console ? – GoodSp33d Oct 30 '12 at 18:06
  • I am fairly new to Drupal development. I am not sure what you mean by input format and error console. – user320691 Oct 30 '12 at 18:27

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.