the request.body
contains this:
"event=project.status.update&project_id=807276&project_status_code=in_progress"
but when I do:
json.loads(request.body)
I am getting:
ValueError: No JSON object could be decoded
what am I doing wrong?
the request.body
contains this:
"event=project.status.update&project_id=807276&project_status_code=in_progress"
but when I do:
json.loads(request.body)
I am getting:
ValueError: No JSON object could be decoded
what am I doing wrong?
request.body
contains form-encoded data, not json-encoded data. This is automatically decoded to a Python dict in request.POST
. So, instead of using request.body
directly with json.loads
, you should be using request.POST
.
json.dumps
takes a python dictionary/JSON object and the counter function, json.loads
takes a json string.
You can't do dumps/loads on a form encoded string.
Whoever is making this http request, they can do JSON.stringify
, make a valid json string out of form data object, set their Content-type
, header as application/json
and send it
Your JSON string must be like the below one in order to use json.loads()
'{
"event": "project.status.update",
"project_id": "807276",
"project_status_code": "in_progress"
}'