Drupal-8 calms HTML-only web services

I have just configured Drupal 8.0 beta 12 with HAL, HTTP Authentication Base, RESTful Web Services and Serialization. The installation is located in a subfolder (D8_beta12). When I access web services for the first page created (id = 1), for example

curl -H "Accept: application/json" --request GET http://localhost/d8_beta12/node/1

DRUPAL provides only the HTML node format. I tried to configure only JSON through REST UI, but this did not help. DRUPAL will respond to requests even if web services are disabled.

This is probably the user who is sitting in front of DRUPAL, who is the problem (s), but I do not understand this. Any help is appreciated - I worked on it, looking through all the DRUPALs forums here too.

Thanks Andi

+4
source share
3 answers

aaplication/json application/hal+json.

curl -H "Accept: application/hal+json" --request GET http://localhost/d8_beta12/node/1

.

+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

to support all of the above formats, you need to make support for this format from the rest configuration from the admin panel, and even you need to provide permission to call back from the permissions page for an anonymous user.

+1
source

All Articles