0

I've created a bunch of custom content types like "Car Makes" and "Car Models", but I can't seem to figure out how to enable a REST resource for them. In my REST settings page, I see the default content, content type, user, user registration enabled and a lot of disabled types below it. This list doesn't contain any of my custom created types.

If I go to the permissions page, under "RESTful Web Services", I only see "Administer REST resource configuration" and "Access POST on User registration resource". How can I enable "Car Makes" as a REST resource and directly GET/POST with it?

I saw this screenshot, but I don't get anything like this in Drupal 8.4:

enter image description here

In this screenshot, Todo is a custom resource, which requires writing a plugin. Do I have to write a plugin module just to expose each of my custom content types in REST?

I can work directly with the content endpoints, i.e. POST /node/123, but I would like to POST /carmakes, for example.

1 Answer 1

0

If you want to access these types of content separately, you must do the following:

  1. download the module restui: https://www.drupal.org/project/restui/releases/8.x-1.x-dev

  2. Go to Extend, activate the modules, HAL, HTTP Basic Authentication, RESTful Web Services, Serialization, and REST UI.

  3. go to / admin / config / services / rest

  4. Edit the RESOURCE NAME Content, and mark all the checkboxes.

  5. Then you should perform a test in the browser with the following path: drupal8 / node / 1? _format = json

note: if the information is displayed, it means that the rest server is set correctly.

  1. Create a view and select the type of content you want to display and in the "REST EXPORT SETTINGS" section mark the "Provide a REST export" checkbox and in "REST export path" type "car_makes".

This way if you go to the route: / drupal8 / en / car_makes you will see that it will show the information in json format.

3
  • I have already done this. It is only for viewing the resource. I would also like to POST, PATCH and DELETE this resource.
    – aalaap
    Oct 26, 2017 at 13:47
  • You can use the gerenal view "/ drupal8 / car_makes" to display the content related to this type of content. To do the "post, get, path, delete" you must use the path: "drupal8 / node / 1? _format = json" I made a video in Spanish, in which I do the "post, get, path delete". The video has a subtitle in English. youtube.com/… Oct 26, 2017 at 15:15
  • 1
    That's the same as the answer above.
    – aalaap
    Oct 27, 2017 at 11:26

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.