Drupal 8 REST
rest/session/token
Authorization(username:password encoded)
X-CSRF-Token(token)
Content-Type(=hal+json) - The response type format. Try use hal+json
User should also have the right permission to do the operation
**GET** http://phenix.mda-geneve.ch/node/12?_format=hal_json
**POST** http://phenix.mda-geneve.ch/entity/node
{
"type":[{"target_id":"article"}],
"title":[{"value":"Hello World"}],
"body":[{"value":"How are you?"}]
}
**PATCH** http://phenix.mda-geneve.ch/node/id
{
"nid":[{"value":"15"}],
"type":[{"target_id":"article"}],
"title":[{"value":"Goodbye World"}]
}
**GET** http://phenix.mda-geneve.ch/profile/2?_format=hal_json
**POST** http://phenix.mda-geneve.ch/entity/profile
{
"type":[{"target_id":"membre"}],
"field_civilite":[{"value":"Monsieur"}],
"field_nom":[{"value":"Cyril"}],
"field_prenom":[{"value":"BOISSENIN"}],
"uid":[{"target_id": 1}]
}
**GET** http://phenix.mda-geneve.ch/admin/structure/eck/entity/line_item/1?_format=hal_json
**PATCH** http://phenix.mda-geneve.ch/admin/structure/eck/entity/line_item/1
REQUEST BODY
{
"_links": {
"type": {
"href": "http://phenix.drupalvm.dev/rest/type/line_item/simple"
}
},
"field_status": [
{
"value": "unpaid"
}
]
}
**GET** http://phenix.mda-geneve.ch/admin/structure/eck/entity/invoice/1?_format=hal_json
**POST** http://phenix.mda-geneve.ch/entity/invoice
REQUEST BODY
{
"_links": {
"type": {
"href": "http://phenix.mda-geneve.ch/rest/type/invoice/member"
}
},
"type": [
{ "target_id": "member" }
],
"field_invoice_model": [
{ "value": "membership" }
],
"title": [
{
"value": "Invoice title ",
"lang": "fr"
}
]
}
Additional links and ressources for future implementations :
https://www.chapterthree.com/blog/custom-restful-api-drupal-8
https://www.drupal.org/docs/8/api/restful-web-services-api/restful-web-services-api-overview
Enable core REST module
Install REST UI
https://www.drupal.org/project/restui