Skip to content

Instantly share code, notes, and snippets.

@giorgian
Created February 11, 2013 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giorgian/4754737 to your computer and use it in GitHub Desktop.
Save giorgian/4754737 to your computer and use it in GitHub Desktop.
Trying to create (or update) a data bag item via Chef REST API (using a non-ruby client), a key `action` gets removed
// Trying to create a data bag item foo bar with the following json via REST API:
{
"id": "bar",
"key": "value",
"action": "remove"
}
// The POST succeeds, but then the content of the data bag item is:
{
"id": "bar",
"key": "value"
}
// This is instead the body of the POST sent by knife data bag from file foo
{
"name": "data_bag_item_foo_bar",
"json_class": "Chef::DataBagItem",
"chef_type": "data_bag_item",
"data_bag": "foo",
"raw_data": {
"id": "bar",
"key": "value",
"action": "remove"
}
}
@giorgian
Copy link
Author

Sniffing local traffic on the server, I captured this piece of internal communication:

{
  "action": "add",
  "payload": {
    "database": "chef_6b9041972ab04993b137b79597c1e976",
    "id": "f85b20a9-e4ef-4a46-8fb9-14e5bea89c92",
    "type": "data_bag_item",
    "item": {
      "id": "bar",
      "chef_type": "data_bag_item",
      "data_bag": "foo",
      "key": "value"
    },
    "enqueued_at": 1360332842
  }
}

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