我有一个新配置的Drupal 8.0 beta 12,支持HAL,HTTP基本身份验证,RESTful Web服务和序列化模块。安装位于子文件夹(D8_beta12)中。当我访问创建的第一个页面(id = 1)的Web服务时,如
curl -H "Accept: application/json" --request GET http://localhost/d8_beta12/node/1
DRUPAL仅提供节点的HTML格式。我试图通过REST UI配置为JSON但这没有帮助。即使Web服务被禁用,DRUPAL也会回答请求。
可能是坐在DRUPAL面前的用户,问题是谁(我) - 但我不明白。任何帮助都表示赞赏 - 我一直在努力工作,审查所有DRUPALs论坛以及此处。
谢谢, 岸堤
答案 0 :(得分:2)
我得到了同样的信息并找到了关于它的说明https://drupal.stackexchange.com/questions/161421/d8-services-errors-no-route-found-for-the-specified-formats
所以我将请求更新为:
{{1}}
更新:在webchick slideshare中找到关于它的说明: http://www.slideshare.net/webchickenator/plain-english-guide-to-drupal-8-criticals/51
答案 1 :(得分:1)
请尝试将aaplication/json
替换为application/hal+json
。
curl -H "Accept: application/hal+json" --request GET http://localhost/d8_beta12/node/1
您可能还想浏览this precise tutorial。
答案 2 :(得分:1)
来自邮递员,如果你正在尝试或从其他休息api,你正在尝试确保你遵循以下格式
http://localhost/da/drupal819/node/253?_format=json
output
{
"nid": [
{
"value": "253"
}
],
"uuid": [
{
"value": "6f255c93-6886-4c38-b4cb-c40469073d1c"
}
],
"vid": [
{
"value": "253"
}
],
"langcode": [
{
"value": "en"
}
],
"type": [
{
"target_id": "article",
"target_type": "node_type",
"target_uuid": "ee2c7b5e-d57e-4714-9193-daff153c63ff"
}
],
"title": [
{
"value": "Commodo Pagus Quia"
}
],
"uid": [
{
"target_id": "14",
"target_type": "user",
"target_uuid": "0b8602ec-8003-4e3d-8406-5bd53e47df71",
"url": "/da/drupal819/user/14"
}
],
"status": [
{
"value": "1"
}
],
"created": [
{
"value": "1474126412"
}
],
"changed": [
{
"value": "1474175616"
}
],
"promote": [
{
"value": "1"
}
],
"sticky": [
{
"value": "0"
}
],
"revision_timestamp": [
{
"value": "1474175616"
}
],
"revision_uid": [
{
"target_id": "14",
"target_type": "user",
"target_uuid": "0b8602ec-8003-4e3d-8406-5bd53e47df71",
"url": "/da/drupal819/user/14"
}
],
"revision_log": [],
"revision_translation_affected": [
{
"value": "1"
}
],
"default_langcode": [
{
"value": "1"
}
],
"path": [],
"body": [
{
"value": "Duis revitas melior paulatim quibus quidne rusticus velit vereor.\n\n",
"format": "plain_text",
"summary": "Duis vitas melior paulatim quibus quidne rusticus velit vereor.\n\n"
}
],
"comment": [
{
"status": "2",
"cid": "165",
"last_comment_timestamp": "1474175616",
"last_comment_name": "",
"last_comment_uid": "13",
"comment_count": "1"
}
],
"field_image": [
{
"target_id": "248",
"alt": "Diam iriure neo quadrum refero valetudo verto ymo.",
"title": "Os patria refoveo si valetudo.",
"width": "225",
"height": "526",
"target_type": "file",
"target_uuid": "02050136-7a51-4183-9c28-7d7cc793183a",
"url": "http://localhost/da/drupal819/sites/default/files/2016-09/gen8C.tmp.jpeg"
}
],
"field_tags": []
}
您也可以尝试其他格式
1)http://localhost/da/drupal819/node/253?_format=hal_json
2)http://localhost/da/drupal819/node/253?_format=xml
要支持以上所有格式,您需要从管理面板的其他配置中获取该格式支持 甚至你需要为匿名用户的权限页面提供获得休息呼叫的权限。