Skip to content

Instantly share code, notes, and snippets.

@rteijeiro
Created August 8, 2015 08:34
Show Gist options
  • Select an option

  • Save rteijeiro/3c2390b98a1ad7d891f5 to your computer and use it in GitHub Desktop.

Select an option

Save rteijeiro/3c2390b98a1ad7d891f5 to your computer and use it in GitHub Desktop.
# GET Node in hal+json format
curl -v -H "Accept:application/hal+json" --request GET http://127.0.0.1:8080/drupal/node/1?_format=hal_json
# GET Node in json format
curl -v -H "Accept:application/json" --request GET http://127.0.0.1:8080/drupal/node/1?_format=json
# POST Node in hal+json format
curl --include --request POST --user user:pass --header 'Content-type: application/hal+json' http://127.0.0.1:8080/drupal/entity/node --data-binary '{"_links":{"type":{"href":"http://127.0.0.1:8080/drupal/rest/type/node/article"}}, "title":[{"value":"Node created using curl at Drupalaton 2015"}], "body": [{"value":"This is the body of the node created using curl at Drupalaton 2015. Are you having fun?"}]}'
# Update Node using PATCH
curl --include --request PATCH --user user:pass --header 'Content-type: application/hal+json' http://127.0.0.1:8080/drupal/node/2 --data-binary '{"_links":{"type":{"href":"http://127.0.0.1:8080/drupal/rest/type/node/article"}}, "title":[{"value":"Welcome to Drupalaton 2015"}], "body": [{"value":"This is the body of the node updated using curl. Do not miss the party tonight!!"}]}'
# DELETE Node
curl --include --request DELETE --user user:pass --header 'Content-type: application/hal+json' http://127.0.0.1:8080/drupal/node/2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment