4

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

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

DRUPAL only delivers HTML format of the node. I have tried to configure via REST UI to JSON only but that didn't help. DRUPAL would answer the requests even if the web services are disabled.

Its probably the user, who's sitting in front of DRUPAL, who is the problem (me) - but I don't get it. Any help deply appreciated - I have been working hours on this, reviewing all of DRUPALs forums and here as well.

Thanks, Andi

alanbuchanan
  • 3,993
  • 7
  • 41
  • 64
andi
  • 41
  • 3

3 Answers3

2

I was getting the same and found a note about it https://drupal.stackexchange.com/questions/161421/d8-services-errors-no-route-found-for-the-specified-formats

So I updated the request to :

node/1?_format=json

Update: Found note about it in a webchick slideshare: http://www.slideshare.net/webchickenator/plain-english-guide-to-drupal-8-criticals/51

Community
  • 1
  • 1
paul.linney
  • 311
  • 1
  • 3
  • Thank you! And a note for others: cookie auth needs to be selected in admin/config/services/rest – Stefan Jul 05 '15 at 19:11
1

Please try replacing aaplication/json with application/hal+json.

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

You may also like to go through this precise tutorial.

Pralhad Narsinh Sonar
  • 1,406
  • 1
  • 14
  • 23
1

from postman if you are trying or from other rest api you are trying make sure you follow below format

    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": []
}

you can try other format as well

1) http://localhost/da/drupal819/node/253?_format=hal_json

2) http://localhost/da/drupal819/node/253?_format=xml

to support all above format you need to make that format support from rest configuration from admin panel and even you need to provide get permission for rest call from permission page for anonymous user.