title: I can't get JSON objects from a REST API URL
body: <p>So I have been trying to retrieve JSON files which are basically posts from my database. They can be fetched from the Django REST API that I am running. I can access the url and see the available posts from any devices within my network. However, I can't retrieve them so that they can be posted on my Android app.</p>
  
  <p>My Log in the <code>postExecute</code> of my <code>AsyncTask</code> doesn't show any JSON objects and is just empty.</p>
  
  <p>It doesn't return any error messages in my logcat so I am not sure what is the problem. </p>
  
  <p>I am trying to make a prototype social networking type stuff where the posts are stored in a database inside my database and fetch them through the API.</p>
  
  <p>I am using <code>AsyncTask</code> to connect to my URL and do processing there</p>
  
  <p>Posts.java</p>
  
  <pre><code>public class Posts extends AppCompatActivity {
  
      @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_posts);
  
              PostsDetails postDetailsHelper = new PostsDetails();
  
              postsDoneBtn = (Button) findViewById(R.id.PostsDoneButton);
  
              postDetailsHelper.callPostDetails("192.168.0.18:8000/api/");
  
              postDetailsHelper.postDetailsCalled('n');
  
              postsDoneBtn.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                      startActivity(new Intent(Posts.this, MainActivity.class));
  
                  }
              });
          }
  
          public class PostsDetails {
  
              // calls the execute for AsyncTask
              private void callPostDetails(String theurl){
                  PostsHelper = new WSAdapter.SendPostsRequest();
                  // sets if post details are called
                  postDetailsCalled('y');
                  // executes AsyncTask
                  PostsHelper.execute(theurl);
              }
  
          }
  
  }
  </code></pre>
  
  <p>WSAdapter.java</p>
  
  <pre><code>public class WSAdapter extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
      }
  
      static public class SendPostsRequest extends AsyncTask&lt;String, String, String&gt; {
  
          // Add a pre-execute thing
          HttpURLConnection urlConnection;
  
          @Override
          protected String doInBackground(String... params) {
  
              StringBuilder result = new StringBuilder();
  
              try {
                  urlConnection = (HttpURLConnection) new URL(params[0]).openConnection();
                  urlConnection.setRequestMethod("GET");
                  urlConnection.connect();
  
                  InputStream in = new BufferedInputStream(urlConnection.getInputStream());
  
                  BufferedReader reader = new BufferedReader(new InputStreamReader(in));
  
                  String line;
                  while ((line = reader.readLine()) != null) {
                      result.append(line);
                  }
  
              }catch( Exception e) {
                  e.printStackTrace();
              }
  
              return result.toString();
          }
  
          @Override
          protected void onPostExecute(String result) {
  
              // expecting a response code fro my server upon receiving the POST data
              Log.e("TAG", result);
  
      }
  }
  </code></pre>