Androidアプリから、Herokudjangoソリューションにデータを投稿しています。
ただし、djangoアプリはデータを受信しません。
curl(insteat android app)を使用したテストこのログを取得します:
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
リダイレクトに問題があるようです。curl(android)はリダイレクト操作後にPOSTデータを送信しないようです。
この動作を修正するにはどうすればよいですか、または回避策は何ですか?
受信したデータをテストするための私のdjangoビュー:
@csrf_exempt
def receive_JSON(request ):
return HttpResponse("Rebut: {0}".format( len( request.raw_post_data ) ) )
データを送信するには、AndroidでRequestを介してJSONオブジェクトを送信する方法を使用しますか? (httpost.setHeader( "Content-type"、 "application / json");)
注意:これは、runserverを使用するローカルで正常に機能します。