Skip to content

Instantly share code, notes, and snippets.

@alex-moreno
Last active September 3, 2016 17:57
Show Gist options
  • Save alex-moreno/d61cf059b16cd00d5c536addb45c1895 to your computer and use it in GitHub Desktop.
Save alex-moreno/d61cf059b16cd00d5c536addb45c1895 to your computer and use it in GitHub Desktop.
Create a new content in Drupal via rest api
curl --include --request POST --user user:pass --header 'Content-type: application/hal+json' --header 'X-CSRF-Token: <obtained from http://example.com/rest/session/token>' http://local.drupal8.com/entity/node?_format=hal_json --data-binary '{"_links":{"type":{"href":"http://local.drupal8.com/rest/type/node/cruise"}},"title":[{"value":"Example node title"}],"type":[{"target_id":"article"}]}'
curl --include --request POST --user user:pass --header 'Content-type: application/hal+json' --header 'X-CSRF-Token: <obtained from http://example.com/rest/session/token>' http://local.drupal8.com/entity/node?_format=hal_json --data-binary '{"_links":{"type":{"href":"http://local.drupal8.com/rest/type/node/cruise"}},"title":[{"value":"Mediterranean cruise adventure"}],"type":[{"target_id":"cruise"}]}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment