Last active
March 12, 2021 13:04
-
-
Save andriyun/3f15a0edab5ccf8db53c1890e7007bd2 to your computer and use it in GitHub Desktop.
Drupal Rest API Create/Update entities
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See this article https://www.drupal.org/docs/8/core/modules/rest/overview
for more info