2011-05-14 8 views
40

私が取り組むAndroidアプリのjavaにはJSONデータを投稿しようとしています。以下は有効か、別の方法でJSON文字列をプッシュする必要がありますか?javaのhttp投稿の本文にjsonを追加するには

HttpPost httpost = new HttpPost("http://test.localhost"); 
httpost.setEntity(new StringEntity("{\"filters\":true}")); 
httpost.setHeader("Accept", "application/json"); 
httpost.setHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8"); 
//... other java code to execute the apache httpclient 

あなたは"application/json"Content-Typeヘッダーを設定する必要があり、事前に

答えて

41

、ありがとうございました。他のすべてはよさそうだ。

関連する問題