Skip to content

Instantly share code, notes, and snippets.

@andriyun
Last active March 12, 2021 13:04
Show Gist options
  • Save andriyun/3f15a0edab5ccf8db53c1890e7007bd2 to your computer and use it in GitHub Desktop.
Save andriyun/3f15a0edab5ccf8db53c1890e7007bd2 to your computer and use it in GitHub Desktop.
Drupal Rest API Create/Update entities
# Create
curl --include \
--request POST \
--user admin:admin \
--header 'Content-type: application/hal+json' \
http://drift.docksal/entity/node?_format=hal_json \
--data-binary '{"_links":{"type":{"href":"http://drift.docksal/rest/type/node/article"}},"title":[{"value":"Example node title"}],"type":[{"target_id":"article"}]}'
# Update
curl --include \
--request PATCH \
--user admin:admin \
--header 'Content-type: application/hal+json' \
http://drift.docksal/node/5?_format=hal_json \
--data-binary '{"_links":{"type":{"href":"http://drift.docksal/rest/type/node/article"}},"title":[{"value":"Example node title updated"}],"type":[{"target_id":"article"}]}'
# Get
curl --include \
--request GET \
--user admin:admin \
--header 'Content-type: application/hal+json' \
http://drift.docksal/rest-example?_format=hal_json
@andriyun
Copy link
Author

andriyun commented Mar 11, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment