0

I'm creating an API service using Services (Drupal 7) and would like to create an URL like /api/avu/v1/{id}.

I have api in Path to endpoint and in hook_services_resources() I have $resources['avu'] with

"args" => array(
   array(
     "name" => "id",
     "optional" => false,
     "source" => array("path" => 0),
     "type" => "int",
     "description" => "The id of the course to retrieve."
   )
),

So /api/avu/{id} works but I can't figure out how to add v1.

0

All I had to do was to add another argument and clear the cache.

"args" => array(
   array(
     "name" => "version",
     "optional" => false,
     "source" => array("path" => 0),
     "type" => "string",
     "description" => "The API version."
   ),
   array(
     "name" => "id",
     "optional" => false,
     "source" => array("path" => 1),
     "type" => "int",
     "description" => "The id of the course to retrieve."
   )
),

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.