Browse files

Fix JSON access method in data bag create API

  • Loading branch information...
1 parent aa7a366 commit 30a62874ca9cf3044c24aa43c2d9c9ed5997c930 @bitprophet bitprophet committed May 30, 2012
Showing with 5 additions and 4 deletions.
  1. +5 −4 commis/data_bags/
@@ -31,12 +31,13 @@ def get_data(self, request, bag):
@api('POST', admin=True)
def item_create(self, request, name):
- if not request.json or 'id' not in request.json:
+ json = request.json.get('raw_data', {})
+ if not json or 'id' not in json:
raise ChefAPIError(500, 'No item ID specified')
bag = self.get_or_404(name)
- if bag.items.filter(name=request.json['id']).exists():
- raise ChefAPIError(409, 'Data bag item %s::%s already exists', name, request.json['id'])
- bag.items.create(name=request.json['id'], data=request.raw_post_data)
+ if bag.items.filter(name=json['id']).exists():
+ raise ChefAPIError(409, 'Data bag item %s::%s already exists', name, json['id'])
+ bag.items.create(name=json['id'], data=request.raw_post_data)
return request.json

0 comments on commit 30a6287

Please sign in to comment.