我有一个新配置的Drupal8.0beta12,启用了HAL,HTTP Basic Authentication,RESTful Web Services和Serialization模块。安装程序位于一个子文件夹(D8_beta12)中。当我访问创建的第一个页面(id=1)的web服务时,如下所示
curl -H "Accept: application/json" --request GET http://localhost/d8_beta12/node/1DRUPAL只提供HTML格式的节点。我尝试通过REST UI仅配置到JSON,但没有帮助。即使web服务被禁用,DRUPAL也会响应请求。
可能是用户,谁坐在DRUPAL前面,谁是问题(我)-但我不明白。非常感谢任何帮助-我已经在这上面工作了几个小时,审查了所有的DRUPAL论坛和这里。
谢谢,安迪
发布于 2015-07-06 02:16:30
我得到了同样的东西,发现了一张关于它的便条https://drupal.stackexchange.com/questions/161421/d8-services-errors-no-route-found-for-the-specified-formats
因此,我将请求更新为:
node/1?_format=json更新:在webchick slideshare中找到了有关它的注释:http://www.slideshare.net/webchickenator/plain-english-guide-to-drupal-8-criticals/51
发布于 2015-07-05 22:33:18
请尝试用application/hal+json替换aaplication/json。
curl -H "Accept: application/hal+json" --request GET http://localhost/d8_beta12/node/1您可能还想通过this precise tutorial查看一下。
发布于 2016-09-19 07:12:06
从postman如果您正在尝试或从其他rest 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
要支持所有上述格式,您需要从管理面板的rest配置中支持该格式,甚至需要从匿名用户的权限页面为rest调用提供获取权限。
https://stackoverflow.com/questions/31230351
复制相似问题