Skip to content

Instantly share code, notes, and snippets.

@chashmeetsingh
Created January 5, 2017 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chashmeetsingh/f6dec99887ddaec1d042f8de0e9cce65 to your computer and use it in GitHub Desktop.
Save chashmeetsingh/f6dec99887ddaec1d042f8de0e9cce65 to your computer and use it in GitHub Desktop.
List<NameValuePair> someVariable = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("query", "{articles{id}}"));
HttpClient httpclient=new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://udacity-alumni-api.herokuapp.com/graphql");
httppost.setHeader(HTTP.CONTENT_TYPE,"application/x-www-form-urlencoded;charset=UTF-8");
try {
httppost.setEntity(new UrlEncodedFormEntity(someVariable, "UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
// Execute HTTP Post Request
try {
HttpResponse response = httpclient.execute(httppost);
Log.d("Response:" , response.toString());
} catch (IOException e) {
e.printStackTrace();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment