Skip to content

Instantly share code, notes, and snippets.

@garrypolley
Last active April 9, 2017 20:37
Show Gist options
  • Save garrypolley/3f36d3fa0c8b1c4c7e39 to your computer and use it in GitHub Desktop.
Save garrypolley/3f36d3fa0c8b1c4c7e39 to your computer and use it in GitHub Desktop.
Example of a "bulk" update to a collection using JSON API Patch extension http://jsonapi.org/extensions/jsonpatch/

Below is an example request that updates all cards that are playing cards without a sleeve to have an attribute of mayGetDirty as true.

HTTP PATCH https://api.example.com/cards?type=Playing&hasSleeve=False

BODY
 [
    {
      "op": "replace",
      "path": "/mayGetDirty",
      "value": true
      }
 ]

Updating two attributes looks like:

HTTP PATCH https://api.example.com/cards?type=Playing&hasSleeve=False

BODY
 [
    {
      "op": "replace",
      "path": "/mayGetDirty",
      "value": true
      },
    {
      "op": "replace",
      "path": "/buySleeveSoon",
      "value": true
      }
 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment