Template:Base Code for Consuming API Using Java

From Updox API
Revision as of 12:20, 18 November 2013 by Thenate (Talk | contribs)

Jump to: navigation, search
 private void SendReceiveJSON(String json, String url) throws Exception { 
    HttpClient httpClient = new DefaultHttpClient();
    try {
      HttpPost request = new HttpPost(url);
      request.addHeader("content-type", "text/json");
      request.setEntity(json);
      HttpResponse response = httpClient.execute(request);
    } catch (Exception ex) {
      // handle exception here
    } finally {
      httpClient.getConnectionManager().shutdown();
    }
 }