0

I have a strange problem. This is my code:

function bd7_services_services_resources() {
  return array(
      'get' => array(
        'index' => array(
          'help' => 'Ritorna le immagini inserite.',
          'callback' => 'bd7_services_get_immagini',
          'access callback' => 'user_access',
          'access arguments' => array('access content'),
          'access arguments append' => FALSE,
        ),

          'actions' => array (
            'immagini' =>
              array(
                'help' => 'Ritorna le immagini inserite.',
                'callback' => 'bd7_services_get_immagini',
                'access callback' => 'user_access',
                'access arguments' => array('access content'),
                'access arguments append' => FALSE,
              ),
          ),
          'operations' => array(
              // Define the index callback for a GET to /cart.
            'immagini2' =>
              array(
                'help' => 'Ritorna le immagini inserite.',
                'callback' => 'bd7_services_get_immagini',
                'access callback' => 'user_access',
                'access arguments' => array('access content'),
                'access arguments append' => FALSE,
              ),
          ),


      )


  );
}

If I call "rest/get" all works.

If I call "rest/get/immagini" I receive "404 Not found : Could not find the controller."

If I call "rest/get/immagini2" I receive "404 Not found : Could not find the controller."

Where is my error ? "rest" is my "Path to endpoint".

Thanks.

  • Enable service callback in service configuration – Rupesh May 16 '15 at 12:18
  • Rupesh: all "get" checkbox are checked in my configuration setting page. – ZioBudda May 16 '15 at 17:38
  • 1
    You have to use a POST call to access your actions. – tyler.frankenstein May 17 '15 at 15:08
1

I have also create custom resource using services module like:

function vintervals_resource() {
  $api = array(
'registration' => array( // Resource name 
'operations' => array(
    'create' => array(
    'help' => 'Ticket System',
    'file' => array(
        'type' => 'inc',
        'module' => 'My_module_name',
        'name' => 'includes/My_module_name.services',
    ),
    'callback' => 'My_custom_callback', // callback
    'access callback' => 'user_access',
    'access arguments' => array('access content'),
    'access arguments append' => FALSE,
    'args' => array(
        array(
        'name' => 'body', // parameter name in callback
        'type' => 'string',
        'description' => 'Function to perform',
        'source' => 'data',
        'optional' => FALSE,
        'default' => '0',
        ),
    ),
    ),
    ),
)
);
return $api;
}
   // callback
 function My_custom_callback($body)
 {
      // Your work here..
      $json_array = array($body);
      $json = json_encode($json_array);
      $body_Array = json_decode($json);
      $applicationId = $body_Array[0]->appno;
      $emailid = $body_Array[0]->emailid;
      $mobileNo = $body_Array[0]->mobno;
      $password = $body_Array[0]->userpwd;
      $returnArray = array('status'=>FALSE,'application_status'=>-1);
      return $returnArray;
 }

URL of my web service call is :

My domain + My endpoint + resourcename

"mydomain.com"+"api/ticketsystem"+"registration"

But it will not working directly in the browser. For this I have sent post request to server with parameters and receive it in my callback then it's working perfectly.

| 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.