Exception android.os.NetworkOnMainThreadException","code":"503"
<p>here is my code:</p>

<pre><code>private static JSONObject doGetRequest(String url) throws JSONException {
    System.out.println("doGetRequest &gt; url : " + url);
    JSONObject json = null;
    HttpClient httpClient = new DefaultHttpClient();
    HttpGet httpGet = new HttpGet(url);
    HttpResponse response;
    System.out.println("doGetRequest &gt; httpGet " + httpGet);
    try {
        System.out.println("doGetRequest &gt; before response ");
        response = httpClient.execute(httpGet);
        System.out.println("doGetRequest &gt; response " + response);
        if(response.getStatusLine().getStatusCode() == 200) {
            HttpEntity entity = response.getEntity();
            if (entity != null) {
                InputStream instream = entity.getContent();
                String result = convertStreamToString(instream);
                instream.close();

                json = new JSONObject(result);
            }
        } else {
            json = oDeskRestClient.genError(response.getStatusLine().getStatusCode(), response.getStatusLine().toString());
        }
    } catch (ClientProtocolException e) {
        json = oDeskRestClient.genError(HTTP_RESPONSE_503, "Exception: ClientProtocolException");
    } catch (IOException e) {
        json = oDeskRestClient.genError(HTTP_RESPONSE_503, "Exception: IOException");
    } catch (JSONException e) {
        json = oDeskRestClient.genError(HTTP_RESPONSE_503, "Exception: JSONException");  
    } catch (Exception e) {
        json = oDeskRestClient.genError(HTTP_RESPONSE_503, "Exception: Exception " + e.toString());
    } finally {
        httpGet.abort();
    }
    System.out.println("doGetRequest &gt; json: " + json);
    return json;
}
</code></pre>

<p>I'm getting exception : Exception android.os.NetworkOnMainThreadException","code":"503"
on this line : HttpClient httpClient = new DefaultHttpClient();</p>

<p>Can anyone help me to resolve this error?</p>

<p>Thanks</p>
