title: API Call from java, weird results?
body: <p>So i am working on a project that involves a java application making calls to our API. It has to send data over GET and up until this point i could do it without any problems, however, i am trying to send a json string as one of the GET parameters.</p>
  
  <p>Now, on the API, the GET variable will be empty when the call is made, however if i use 'print_r' or 'var_dump' on the API page when it is called, it magically works. (Obvious sarcasam)</p>
  
  <p>I know that might sound confusing, that would be because it is. I havent had any problems making my calls up until this point.</p>
  
  <p>My non-working code: (throws one of the errors.)</p>
  
  <p>PHP</p>
  
  <pre><code>$checking = array(1, 2, 3);
  $data = json_decode(base64_decode(urldecode($_GET['update'])), true);
  if(!isset($data))
  {
      exit(json_encode(array("Error"=&gt;"Invalid data")));
  
  }
  if(count($data) != count($checking))
  {
      exit(json_encode(array("Error"=&gt;"Invalid amount: ")));
  }
  </code></pre>
  
  <p>JAVA</p>
  
  <pre><code>List&lt;HashMap&lt;String, Object&gt;&gt; list = new ArrayList&lt;HashMap&lt;String, Object&gt;&gt;();
  
  for(ClientBase pb : this.clients)
  {
      HashMap&lt;String, Object&gt; map = new HashMap&lt;String, Object&gt;();
      map.put("id", pb.id);
      map.put("type", pb.getType());
      map.put("status", pb.getStatus() ? 1 : 0);
      list.add(map);
  }
  
  String out = JSONObject.valueToString(list);
  String newout = new String(Base64.encode(out.getBytes()));
  URLConnection conn = new URL("http://localhost/api/?key=" + Main.INSTANCE.APIKEY + "&amp;update=" + URLEncoder.encode(newout, "UTF- 8")).openConnection();
  InputStream is = conn.getInputStream();
  java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
  res = s.hasNext() ? s.next() : "";
  </code></pre>
  
  <p>This results in one of the errors getting thrown due to the array being empty/null.</p>
  
  <p>Now, if i change my PHP code to:</p>
  
  <pre><code>$checking = array(1, 2, 3);
  $data = json_decode(base64_decode(urldecode($_GET['update'])), true);
  var_dump($data);
  if(!isset($data))
  {
      exit(json_encode(array("Error"=&gt;"Invalid data")));
  
  }
  if(count($data) != count($checking))
  {
      exit(json_encode(array("Error"=&gt;"Invalid amount: ")));
  }
  </code></pre>
  
  <p>then the $data array is populated and no error gets thrown.</p>
  
  <p>I really cant wrap my head around this one, Also i base64 encoded it and urlencoded it in an effort to get this to work.</p>
  
  <p>Thanks for any help</p>