0

I have a custom rest resource I have created within my module:

/**
 * Provides a Demo Resource
 *
 * @RestResource(
 *   id = "custom",
 *   label = @Translation("custom"),
 *   uri_paths = {
 *     "canonical" = "/rest/custom"
 *   }
 * )
 */
class custom extends ResourceBase {
public function get() {
    return new ResourceResponse("Response");
}

I have a rest.resource.custom.yml file in my module/custom/install folder to activate the end point when the module gets installed but it doesnt work:

id: module.custom
plugin_id: 'custom'
granularity: method
status: true
configuration:
  GET:
    supported_formats:
      - json
    supported_auth:
      - cookie

How do you enable rest endpoints when module is installed?

0

The error was in the .yml file with the id: attribute. Dont need to include the module name with it:

id: custom
plugin_id: 'custom'
granularity: method
status: true
configuration:
  GET:
    supported_formats:
      - json
    supported_auth:
      - cookie
| 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.