title: Implementing Jdoodle Compiler API in Java
body: <p>I am making an application which compiles c,c++ and java programs. I am using <strong>Jdoodle Compiler API</strong> for executing the code. Whenever I run the following code it gives me an error, saying <strong>error code = 400.</strong></p>
  <p>This is the code snippet</p>
  <pre><code>Thread thread = new Thread(new Runnable() {
                  @Override
                  public void run() {
                      try {
                          try {
                              String clientId = &quot;af52e5b3d64463*******e4206c055&quot;; //Replace with your client ID
                              String clientSecret = &quot;e868414f5565d10183267d398d5***448c6a1a70bf8be2896******&quot;; //Replace with your client Secret
                              String script = editText.getText().toString();
                              String language = &quot;java&quot;;
                              String versionIndex = &quot;0&quot;;
                              URL url = new URL(&quot;https://api.jdoodle.com/v1/execute&quot;);
                              HttpURLConnection connection = (HttpURLConnection) url.openConnection();
                              connection.setDoOutput(true);
                              connection.setRequestMethod(&quot;POST&quot;);
                              connection.setRequestProperty(&quot;Content-Type&quot;, &quot;application/json&quot;);
                              String input = &quot;{\&quot;clientId\&quot;: \&quot;&quot; + clientId + &quot;\&quot;,\&quot;clientSecret\&quot;:\&quot;&quot; + clientSecret + &quot;\&quot;,\&quot;script\&quot;:\&quot;&quot; + script +
                                      &quot;\&quot;,\&quot;language\&quot;:\&quot;&quot; + language + &quot;\&quot;,\&quot;versionIndex\&quot;:\&quot;&quot; + versionIndex + &quot;\&quot;} &quot;;
                              System.out.println(input);
                              OutputStream outputStream = connection.getOutputStream();
                              outputStream.write(input.getBytes());
                              outputStream.flush();
                              if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
                                  throw new RuntimeException(&quot;Please check your inputs : HTTP error code : &quot; + connection.getResponseCode());
                              }
                              BufferedReader bufferedReader;
                              bufferedReader = new BufferedReader(new InputStreamReader(
                                      (connection.getInputStream())));
                              StringBuilder results = new StringBuilder();
                              String output1;
                              System.out.println(&quot;Output from JDoodle .... \n&quot;);
                              while ((output1 = bufferedReader.readLine()) != null) {
                                  results.append(output1);
                              }
                              connection.disconnect();
                              output.setText(results);
                          } catch (IOException e) {
                              e.printStackTrace();
                          }
                      } catch (Exception e) {
                          e.printStackTrace();
                      }
                  }
              });
              thread.start();
  </code></pre>
  <p>What Should I change in the code to make the app compile the programs</p>