title: Running curl GET request in java gives exit code 3
body: <p>When i run the following command on my shell it gives out the expected JSon output (I'm using macOS). </p>
  
  <pre><code>curl -X GET -H 'Content-Type: application/json' -H 'Authorization: Basic MYKEY’ -i 'http://MYAPI’ --data ‘MYBODY’
  </code></pre>
  
  <p>But if i do the same thing using Java's Runtime.getRuntime().exec (code below) it just returns a exit code 3 (Malformed URL, according to the CURL docs).</p>
  
  <pre><code>import java.io.BufferedReader;
  import java.io.InputStreamReader;
  
  void runCommand("curl -X GET -H 'Content-Type: application/json' -H 'Authorization: Basic MYKEY’ -i ‘http://MYAPI’ --data ‘MYBODY’”) {
  
      String s;
      Process p;
      try {
          p = Runtime.getRuntime().exec(command);
          BufferedReader br = new BufferedReader(
                  new InputStreamReader(p.getInputStream()));
          while ((s = br.readLine()) != null) {
              System.out.println("line: " + s);
          }
          p.waitFor();
          System.out.println("exit: " + p.exitValue());
          p.destroy();
      } catch (Exception e) {
          System.out.println("ERROR");
      }
  }
  </code></pre>
  
  <p>I tried using the same code to run curl on HTML pages (google.com), which works perfectly. What am i doing wrong here? 
  Please note there are restrictions on the API server which forced me to use curl on command line rather than calling it through a library. Thanks so much for any ideas.</p>