I'm learning about web services and implementing it in drupal 6 and am trying to use Services module with its REST server for implementing a web service to add a user.

Since there is an existing functionality for all CRUD operation for users, I am trying to implement my custom code to register a user by using a HTTP POST of the respective data using REST as a part of the challenge. I implemented custom user resource in my module (awesomeness.module) and got it to show up in the list of resources with the respective operation (Create).

 * Implements hook_services_resources().
function awesomeness_services_resources() {
  return array(
    'awesome_registrant' => array(
      'operations' => array(
        'create' => array(
          'file' => array('type' => 'inc', 'module' => 'awesomeness'),
          'callback' => '_create_registrant_from_awesomeness',
          'help' => 'Creates or updates user from the 
                     json data initiated by the Awesomeness request.',
          'access callback' => '_create_registrant_from_awesomeness_permissions',
          'access arguments' => array('dummy'),
          'access callback file' => array('type' => 'inc', 'module' => 'awesomeness'),
          'args' => array(
              'name' => 'user_data',
              'type' => 'string',
              'description' => 'The json data of User posted
                                by Awesomeness to register information.',
              'optional' => FALSE,
              'source' => 'data',

The corresponding callbacks for the request and access in awesomeness.inc are as below

 * Callback function to create or registrant from the web service request
function _create_registrant_from_awesomeness($user_data) {
  watchdog('AwesomeWebservice', "I am called");
  $user_info = var_export($user_data, TRUE);
  watchdog('AwesomeWebservice', $user_info);
  return "Is called";

 * Access callback for the registration Web service.
function _create_registrant_from_awesomeness_permissions($access = TRUE) {
  // any logic on access restriction goes here, currently 
  // setting true to check that calls can be made as an anonymous user
  return TRUE;

I created an endpoint and enabled Create for awesome_registrant and made the POST request with POSTER add-on for firefox set the Content type as application/x-www-form-urlencoded and the following json data in content body {"username":"[email protected]","password":"epicawesomeness"}.

However I merely get a response code of 200 and nothing more where I expect the callback to return "Is called".

Enabling the debug mode shows only the Server info object but not the controller or the data about the return value unlike the core services like node retrieve.

Also for sake of clarification application/x-www-form-urlencoded is enabled for the REST web server. Any help on what I might have missed or where I have erred would be greatly appreciated.

1 Answer 1


Finally figured it out and boy was it bad. The endpoint I was supposed to hit was http://mysite.com/myawesomeendpoint/awesomeregistrant but instead I hit http://mysite.com/myawesomeendpoint. Hope this helps some one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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