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.

Revisions

  1. andriyun revised this gist Mar 12, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion drupal-rest-api-create-update-entities.sh
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@ curl --include \
    --request POST \
    --user admin:admin \
    --header 'Content-type: application/hal+json' \
    http://drift.docksal/node/1?_format=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
  2. andriyun revised this gist Mar 11, 2021. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions drupal-rest-api-create-update-entities.sh
    Original file line number Diff line number Diff line change
    @@ -4,15 +4,15 @@ curl --include \
    --user admin:admin \
    --header 'Content-type: application/hal+json' \
    http://drift.docksal/node/1?_format=hal_json \
    --data-binary '{"_links":{"type":{"href":"http://drift.docksal/rest/type/node/article"}},"title":[{"value":"Example node title updated again"}],"type":[{"target_id":"article"}]}'
    --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":"test"}],"type":[{"target_id":"article"}]}'
    --data-binary '{"_links":{"type":{"href":"http://drift.docksal/rest/type/node/article"}},"title":[{"value":"Example node title updated"}],"type":[{"target_id":"article"}]}'


    # Get
  3. andriyun created this gist Mar 11, 2021.
    23 changes: 23 additions & 0 deletions drupal-rest-api-create-update-entities.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    # Create
    curl --include \
    --request POST \
    --user admin:admin \
    --header 'Content-type: application/hal+json' \
    http://drift.docksal/node/1?_format=hal_json \
    --data-binary '{"_links":{"type":{"href":"http://drift.docksal/rest/type/node/article"}},"title":[{"value":"Example node title updated again"}],"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":"test"}],"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