Re: POSTing JSON to Tastypie from Android

2013-03-24 Thread Pratik Mandrekar
Thanks, I got it to work after much of trial and error. Here is the gist - https://gist.github.com/ratpik/5232763 Thanks, Pratik On Sunday, March 24, 2013 8:46:09 PM UTC+5:30, ke1g wrote: > > There are a couple of standard ways, IIRC, to encode post parameters, but > neither of them is JSON in

Re: POSTing JSON to Tastypie from Android

2013-03-24 Thread Bill Freeman
There are a couple of standard ways, IIRC, to encode post parameters, but neither of them is JSON in the body. Of course you can do as you want, and android apparently does, but other software is unlikely to recognize it. Again, from memory, the two methods are using url encoding, and multi-part

Re: POSTing JSON to Tastypie from Android

2013-03-23 Thread Pratik Mandrekar
Thanks for the pdb tip Bill! I tried pdb at the point where the request enters Tastypie (based on http://stackoverflow.com/questions/13006901/tastypie-obj-create-method-not-being-called). What I see is that the request.POST and request.raw_post_data are both empty. I posted from Android client

Re: POSTing JSON to Tastypie from Android

2013-03-23 Thread Bill Freeman
Still, if you have a break point where the request comes in to the view, you can inspect the POST data to see how it differs from what you expect. That might inform you as to what you might do differently in your JavaScript, whether you need some additional or different encoding or quoting of the d

Re: POSTing JSON to Tastypie from Android

2013-03-23 Thread Pratik Mandrekar
The issue is with setting data in the http post request. I have tried it with curl and the web client and it works. CSRF is not the issue, requests work fine without the csrftoken outside of the android client. Pratik On Saturday, March 23, 2013 12:01:21 AM UTC+5:30, ke1g wrote: > > Have you

Re: POSTing JSON to Tastypie from Android

2013-03-22 Thread Bill Freeman
Have you tried a breakpoint in the view? Might it be a CSRF problem? On Fri, Mar 22, 2013 at 2:22 PM, Pratik Mandrekar wrote: > Hello, > > I'm unable to get the POST json to tastypie from an android http client to > work. > > *I have tried with HttpURLConnection* > > urlConnection = (HttpURLCon

POSTing JSON to Tastypie from Android

2013-03-22 Thread Pratik Mandrekar
Hello, I'm unable to get the POST json to tastypie from an android http client to work. *I have tried with HttpURLConnection* urlConnection = (HttpURLConnection) url.openConnection(); urlConnection.setDoInput(true); urlConnection.setDoOutput(true); urlConnection.setRequestProperty("Content-