Created
March 12, 2014 12:44
-
-
Save guilhermecarvalhocarneiro/9506197 to your computer and use it in GitHub Desktop.
HttpPost Android para API DjangoRestFramework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JSONObject jsonobject = new JSONObject(); | |
HttpClient httpclient = new DefaultHttpClient(); | |
HttpPost httppost = new HttpPost("http://*******/apirestfull/******/"); | |
httppost.setHeader("Content-Type","application/json"); | |
httppost.setHeader("Authentication", "Token 0d0c898a*****e8bd"); | |
jsonobject.put("nome", "Guilherme"); | |
jsonobject.put("pais", "Brasil"); | |
jsonobject.put("chave", Key); | |
httppost.setEntity(new StringEntity(jsonobject.toString(), "UTF-8")); | |
// Execute HTTP Post Request | |
HttpResponse response = httpclient.execute(httppost); | |
Log.i("Resposta", response.getStatusLine().toString()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment