Skip to content

Commit 18a9281

Browse files
author
Dan
committed
Fix bytes -> json bug
1 parent 381afc8 commit 18a9281

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

dj_elastictranscoder/views.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,16 @@ def endpoint(request):
134134
Receive SNS notification
135135
"""
136136
data = {}
137+
138+
# Request body can be bytes or string
137139
try:
138-
data = json.loads(request.body)
139-
except ValueError:
140+
request_body = request.body.decode("utf-8")
141+
except AttributeError:
142+
request_body = request.body
143+
144+
try:
145+
data = json.loads(request_body)
146+
except ValueError as e:
140147
return HttpResponseBadRequest(str(e))
141148

142149
try:

0 commit comments

Comments
 (0)