0

From an android app I'm POSTing data to an Heroku django solution.

But django app don't receive any data.

Testing with curl (insteat android app) I take this log:

dani@heroku-test:~/tmp$ curl -vd '[{"lat ____some data ___ adf"}]'  \
                        http://myApp.heroku.com/x/receive_JSON/ 

* About to connect() to myApp.heroku.com port 80 (#0)
*   Trying 107.21.106.77... connected
> POST /x/receive_JSON/ HTTP/1.1
> User-Agent: curl/7.22.0 (i686-pc-linux-gnu) 
 libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: myApp.heroku.com
> Accept: */*
> Content-Length: 296                 <---- OK!!!
> Content-Type: application/x-www-form-urlencoded
> 
* upload completely sent off: 296out of 296 bytes
< HTTP/1.1 301 Moved Permanently
< Server: nginx
< Date: Sun, 03 Jun 2012 22:15:13 GMT
< Connection: keep-alive
< Location: http://myApp.herokuapp.com/x/receive_JSON/
< Content-Length: 0                     <-----KO!!!!!!!!!!!!!!!!!!!!!!!!!!
< 
* Connection #0 to host myApp.heroku.com left intact
* Closing connection #0

It seems that is a problem with redirect, it seems that curl (android) don't send POST data after redirect operation.

How can I do to fix this behavior or what may be a workaround?

My django view to test received data:

@csrf_exempt    
def receive_JSON(request ):

    return HttpResponse("Rebut: {0}".format( len( request.raw_post_data ) ) )

To send data I use How to send a JSON object over Request with Android? (also httpost.setHeader("Content-type", "application/json"); )

Notice: this works fine in local with runserver.

Community
  • 1
  • 1
dani herrera
  • 48,760
  • 8
  • 117
  • 177

1 Answers1

4

Solved change url to righ location:

http://myApp.herokuapp.com

instead

http://myApp.heroku.com
dani herrera
  • 48,760
  • 8
  • 117
  • 177