我正在用后端的 Drupal8 编写一个 Angular2 Web 应用程序。我需要将分类 id 转换为它们各自的标签,因为我想使用 API 端点“/taxonomy/term/{taxonomy_term}”。我已启用正确的 REST-API 并授予对所有角色的访问权限,但是当我尝试使用 ID 和 ?_format=json 访问该端点时,我收到消息'{“message”:“不可接受的格式:json “}”。但是,如果我删除 ?format=json,它会给我在 HTML 中想要的结果。
此错误消息位于文件 /core/lib/Drupal/Core/EventSubscriber/AcceptNegotiation406.php 中,前面有以下注释:
// If this is a render array then we assume that the router went with the
// generic controller and not one with a format. If the format requested is
// not HTML though we can also assume that the requested format is invalid
// so we provide a 406 response.
谁能帮我这个?或者,我将不得不从 HTML 结果中删除分类标签。