Hi abh,
On 29 August 2013 23:11, abh2134 <[email protected]> wrote:
> Hi all,
>
> Working with django.test.client.
>
> Running:
> response = self.client.post(url, {"message": "this is a message"}),
> content_type="application/json")
>
> The server receives:
> (Pdb) request.body
> "{'platform': 'ios', 'token': '123abc', 'uuid': 'abc123'}"
>
> ... which is NOT a valid JSON string. A proper JSON dictionary's keys/fields
> are enclosed by double-quotes, not single quotes. See: http://www.json.org/.
It's not a bug. As per documentation:
If you provide content_type (e.g. text/xml for an XML payload),
the contents of data will be sent *as-is* in the POST request, using
content_type in the HTTP Content-Type header.
This means that you're responsible for proper encoding the data
parameter into string/bytes. Otherwise Django will just cast the data
to bytes.
--
Łukasz Rekucki
--
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
For more options, visit https://groups.google.com/groups/opt_out.