0
The response was redirecting me to the custom login-page where I had used @csrf_exempt
. Further login details were required for code to process the info. I added the login parameter along with my call and the desired response was obtained
0
TL;DR
httpconn.setRequestProperty("Accept", "application/json");
HttpURLConnection‘s default “Accept” HttpHeader value is text/html, image/gif, image/jpeg, *; q=.2, /; q=.2
When text/html
is used django returns JSON wrapped with HTML. In case when plain JSON is needed, Accept HttpHeader value should be set to 'application/json'
- [Django]-Django shell doesn't respect cache configuration
- [Django]-How to use ListSerializer with a ModelSerializer?
- [Django]-Getting 'TooBig' Memcachier exception on a Django Rest Framework response on Heroku
- [Django]-NoReverseMatch: with arguments '()' and keyword arguments
- [Django]-Django flatpages and images
Source:stackexchange.com