0

I am using Drupal 10.2.6 and I am trying to get menu items via /jsonapi/system/menu/main/linkset, /jsonapi/system/menu/menu/main/linkset, and /jsonapi/menu/main/linkset, but I always get a 404 error.

The Menu Linkset module is enabled and the CORS are OK.

screenshot

What is the point?

1 Answer 1

1

As per the documentation, the endpoint is at /system/menu/[menu system name]/linkset with no /jsonapi prefix (as the routes are provided by the System module, not the JSON API module).

So for a menu with the machine name main, the endpoint would be /system/menu/main/linkset.

This is also confirmed by core linkset test:

public function testBasicFunctions() {
  $this->enableEndpoint(TRUE);
  $expected_linkset = $this->getReferenceLinksetDataFromFile(__DIR__ . '/../../../fixtures/linkset/linkset-menu-main.json');
  $response = $this->doRequest('GET', Url::fromUri('base:/system/menu/main/linkset'));
  $this->assertSame('application/linkset+json', $response->getHeaderLine('content-type'));
  $this->assertSame($expected_linkset, Json::decode((string) $response->getBody()));

See how the test makes a GET request to base:/system/menu/main/linkset, not base:/jsonapi/system/menu/main/linkset.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.