diff --git a/bin/packages/Item.py b/bin/packages/Item.py index 8331a33a..9c0302a6 100755 --- a/bin/packages/Item.py +++ b/bin/packages/Item.py @@ -226,17 +226,17 @@ def get_item(request_dict): # API as txt def get_item_as_txt(request_dict): + item_id = request_dict.get('id', None) + if not request_dict: return {'status': 'error', 'reason': 'Malformed JSON'}, 400 - item_id = request_dict.get('id', None) if not item_id: return {'status': 'error', 'reason': 'Mandatory parameter(s) not provided'}, 400 if not exist_item(item_id): return {'status': 'error', 'reason': 'Item not found'}, 404 item_content = get_item_content(item_id) - encoded_item_content = item_content.encode("UTF-8") - base64_output = base64.b64encode(encoded_item_content) + base64_output = base64.b64encode(item_content) dict_item = {'id': item_id, 'content': base64_output} return dict_item, 200