I have been working on upgrading my site form Drupal 7 to backdrop CMS. I have faced one problem where one of my custom modules is developed to generate resources for a REST endpoint. On drupal this was done by using the hook_services_resources(), but this does not seem to be the case under Backdrop CMS. So how do i generate the resources for this REST endpoint on Backdrop CMS. Any help will be appreciated! Thanks!
Accepted answer
Comments
Hello @Venky 👋
If I'm not mistaken, hook_services_resources() in D7 was not provided by core, but by the contrib Services API module, which has been ported to Backdrop: https://backdropcms.org/project/services
Have you tried installing that?
Hey @klonos,
I understand the fact that the Services module is the one that is used for this purpose. However, this does not seem to work. The hook_services_resources is not available in the hook system either at https://api.backdropcms.org/api/backdrop/core!includes!module.inc/group/hooks/1. So what am I doing wrong here ?
Hey @klonos,
I figured out what I was doing wrong in generating those REST resources. In my hook.module file, I was calling an unavailable hook like hook_default_services_endpoint in Backdrop CMS. Also, my custom module has another file called the hook_services.inc where I have a valid hook, hook_services_resources(). I stopped using the hook_default_services_endpoint() hook and instead ported the functionality from the hook.services file which is hook_services_resources(). After performing this hook function in the hook.module file and moving the functions in hook_services.inc to hook.module, the problem was fixed.
Thanks!
Glad everything worked in the end @Venky, and thanks for taking the time to report back here 👍
Hey @klonos,
I figured out what I was doing wrong in generating those REST resources. In my hook.module file, I was calling an unavailable hook like hook_default_services_endpoint in Backdrop CMS. Also, my custom module has another file called the hook_services.inc where I have a valid hook, hook_services_resources(). I stopped using the hook_default_services_endpoint() hook and instead ported the functionality from the hook.services file which is hook_services_resources(). After performing this hook function in the hook.module file and moving the functions in hook_services.inc to hook.module, the problem was fixed.
Thanks!