Внедрение Jdoodle

#java #android #android-studio #java-compiler-api

#Ява #Android #android-студия #java-компилятор-api

Вопрос:

Я создаю приложение,которое компилирует программы на c, c и java. Я использую API компилятора Jdoodle для выполнения кода. Всякий раз, когда я запускаю следующий код, он выдает мне ошибку, говоря, что код ошибки = 400.

Это фрагмент кода

 Thread thread = new Thread(new Runnable() {  @Override  public void run() {  try {  try {  String clientId = "af52e5b3d64463*******e4206c055"; //Replace with your client ID  String clientSecret = "e868414f5565d10183267d398d5***448c6a1a70bf8be2896******"; //Replace with your client Secret  String script = editText.getText().toString();  String language = "java";  String versionIndex = "0";  URL url = new URL("https://api.jdoodle.com/v1/execute");  HttpURLConnection connection = (HttpURLConnection) url.openConnection();  connection.setDoOutput(true);  connection.setRequestMethod("POST");  connection.setRequestProperty("Content-Type", "application/json");  String input = "{"clientId": ""   clientId   "","clientSecret":""   clientSecret   "","script":""   script    "","language":""   language   "","versionIndex":""   versionIndex   ""} ";  System.out.println(input);  OutputStream outputStream = connection.getOutputStream();  outputStream.write(input.getBytes());  outputStream.flush();  if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {  throw new RuntimeException("Please check your inputs : HTTP error code : "   connection.getResponseCode());  }  BufferedReader bufferedReader;  bufferedReader = new BufferedReader(new InputStreamReader(  (connection.getInputStream())));  StringBuilder results = new StringBuilder();  String output1;  System.out.println("Output from JDoodle .... n");  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();