As setting up a test environment is cumbersome this project provides for a install and test script.
It has a POST script to try posting entities into Drupal 8
DIY HAL POST a node is https://www.drupal.org/node/2098511
Known issues:
- Config Entities are not available through both REST or HAL. Support ConfigEntity via REST
- REST errors are not informative Serve REST errors as application/api-problem+json OR application/vnd.error+json)
- Manually How to POST a comment and other relational entities
- You should have a running Drupal 8 install
- You must have installed Drush
- You need to know how to write Drush aliases
$ vi ~/.drush/drupal.aliases.drushrc.php
Alias file content:
$aliases['d8'] = array ( 'root' => '/Users/clemens/Sites/drupal/d8/www', 'uri' => 'http://drupal.d8', 'databases' => array ( 'default' => array ( 'default' => array ( 'database' => 'drupal_d8', 'username' => 'drupal_d8', 'password' => 'drupal_d8', 'host' => 'localhost', 'port' => '', 'driver' => 'mysql', 'prefix' => '', ), ), ), );
- Checkout this REPO
- Run ./rest.sh
- Follow the instructions.
To test HAL navigation install https://github.com/mikekelly/hal-browser
Run $ ./rest.sh
gives:
Run with one of the following argument(s) in order of appearance:
Quick start argument sets are:
- install-hal : Quickly installs and configures an empty site for HAL and query for content
- hal-content : Query as admin for all hal configured content
- hal-content-anon : Query as anonymous for all configured content
- hal-9000 : Generate 42 nodes
- json-content : Query as admin for all hal configured content
- json-content-anon : Query as anonymous for all configured content
Step by step arguments are:
- install : reinstalls drupal enable modules and setup config
- install-modules : install contrib modules: devel rest_ui oauth
- install-config : copies the .dist files
- views : tries to install a view for the 'nodes' FIXME
- content : generated the needed data: users nodes comment
- rest-set : enable the rest module disable the hal module and load config
- rest : set the accept header
- hal-set : enable the hal module and load config
- hal : set the accept header
- perms : sets the known permissions for the exposed rest resources
- web : alias for drush user-login
- anon : swith to anonymous user which may not view profile
- nodes : query the configured views is successful. FIXME
- node : query for a node resource
- comment : query for a comment resource
- user : query for a user resource
Create a clear install with supporting modules:
./rest.sh install-modules install ./rest.sh hal-set hal config ./rest.sh hal node comment user # writes node/1 comment/1 and user/1 into /data dir php ./post.php # tries to post new node, comment, user