[Django]-Django APIClient Post Empty

5👍

urlencode your post data and set content_type to application/x-www-form-urlencoded.

from urllib.parse import urlencode  
# In python 2, use this instead: from urllib import urlencode  


response = self.client.post(reverse('SMS-data'), urlencode(postData),
    content_type='application/x-www-form-urlencoded'
)

You will get data in request.POST

Leave a comment