Drupal - Setting Up Drupal 8 REST Post Request
As I still ran into a lot of 403 Forbidden
errors I'll summarize my overall solution here (Drupal 8.0.1):
1.) Setup & Configuration
Enable all core web services modules (HAL, HTTP Basic Authentication, RESTful Web Services, Serialization
Enable relevant permissions of RESTful Web Services and for creating the relevant Nodes.
2.) Get a CSRF Token:
GET http://your-drupal8/rest/session/token
3.) POST to create a new node
POST http://your-drupal8/entity/node?_format=hal+json
Note that the URL for POST seems to be
/entity/node
rather than/node
Headers:
Authorization: Basic QWRt...
X-CSRF-Token: zCf...
Data
{
"title": [
{ "value": "atest2" }
],
"type": [
{ "target_id": "article" }
],
"_links": {
"type": { "href": "http://your-drupal8/rest/type/node/article" }
}
}