Skip to content

Instantly share code, notes, and snippets.

@kurtisdunn
Last active January 6, 2016 06:24
Show Gist options
  • Select an option

  • Save kurtisdunn/2bd6d481010a2bc26b1a to your computer and use it in GitHub Desktop.

Select an option

Save kurtisdunn/2bd6d481010a2bc26b1a to your computer and use it in GitHub Desktop.
Drupal 8 Forums with REST

##Drupal 8 REST End Points and Examples

Headers

####POST to Forums

POST new thread into Forum "Cars"

{
  "_links": {
    "type": {
      "href": "http://d8.dev/rest/type/node/forum?_format=hal_json"
    }
  },
  "type":[{"target_id":"forum"}],
  "title": [{
    "value": "Track days are why saturdays exist."
  }],
  "taxonomy_forums": [{
      "target_id": "19"
  }],
  "body":[{
      "value": "<p>Vestibulum id ligula porta felis euismod semper. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Etiam porta sem malesuada magna mollis euismod.</p>"
  }]
}

POST Comment into thread

{
   "_links":{
      "type":{
         "href":"http://d8.dev/rest/type/comment/comment"
      },
      "http://d8.dev/rest/relation/comment/comment/entity_id":[
         {
            "href":"http://d8.dev/node/76?_format=hal_json"
         }
      ],
      "http://d8.dev/rest/relation/comment/comment/uid":[
         {
            "href":"http://d8.dev/users/11?_format=hal_json",
            "lang":"en"
         }
      ]
   },

  "uid":[{"target_id":11}],
  "entity_id":[{"target_id":"76"}],
  "entity_type":[{"value":"node"}],
  "comment_type":[{"target_id":"comment"}],
  "subject":[{"value":"This is a comment"}],
  "field_name": [
{
"value": "comment_forum"
}
],
  "comment_body":[
    {"value":"<p>Fill me up with you comments!</p>","format":"basic_html"}
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment