I'm using Django REST Framework and all the API calls come from Android and iOS apps. The system works perfectly most of the time, however, when an internal server error happens and I get an email from Django, the POST
of the WSGIRequest
contains <could not parse>
instead of the actual posted JSON data (even though 'CONTENT_TYPE': 'application/json'
is also in the header, and the data is sent as JSON).
This is really annoying, as it would be great to see the request body that actually causes the error, not just the stacktrace.
The <could not parse>
part is very similar to this question (in the ModPythonRequest
part): django request.POST contains <could not parse>, except the actual problem is slightly different. Also the reference link in that question (https://stackoverflow.com/questions/12471661/mod-python-could-not-parse-the-django-post-request-for-blackberry-and-some-andro) seems to have gone down, even though the name looked very promising.
I'm on Django 1.6.2 and DRF 2.3.13.
The POST
dictionary of the WSGIRequest
is always going to be invalid, because it is intended to hold the parsed form data when the Content-Type
is application/x-www-form-urlencoded
or multipart/form-data
.
The data you want is in the body
attribute of the WSGIRequest
object, which isn't output when that object is converted to a string to be written to the log.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With