revsys / django-test-plus

Useful additions to Django's default TestCase

Home Page:https://django-test-plus.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sending JSON String in post request

PabloVallejo opened this issue · comments

I'd love to know how to send a raw JSON string in the request body.
Currently I'm passing the string directly to data, but it specs a dictionary instead.

response = self.post(
    'my-url',
    data=json_string,
)

Any thoughts on this?

You would need to drop back down to using the Django TestClient directly and do something like this: http://stackoverflow.com/a/18176166/12568