Exception in thread "main" java.lang.Error: Unresolved compilation problems:
String cannot be resolved to a type
No exception of type JSONException can be thrown; an exception type must be a subclass of Throwable
String cannot be resolved to a type
URL cannot be resolved to a type
URL cannot be resolved to a type
HttpURLConnection cannot be resolved to a type
HttpURLConnection cannot be resolved to a type
String cannot be resolved to a type
OutputStream cannot be resolved to a type
BufferedReader cannot be resolved to a type
BufferedReader cannot be resolved to a type
InputStreamReader cannot be resolved to a type
String cannot be resolved to a type
String cannot be resolved to a type
System cannot be resolved
System cannot be resolved
MalformedURLException cannot be resolved to a type
IOException cannot be resolved to a type
at testKazooApi.main(testKazooApi.java:13)
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import org.json.JSONArray;
import org.json.JSONException;
public class testKazooApi {
public static void main(String[] args) throws JSONException {
try {
URL targetUrl = new URL(targetURL);
HttpURLConnection httpConnection = (HttpURLConnection) targetUrl.openConnection();
httpConnection.setDoOutput(true);
httpConnection.setRequestMethod("PUT");
httpConnection.setRequestProperty("Content-Type", "application/json");
httpConnection.setRequestProperty("Accept","application/json");
String input = "{\"data\":{ \"credentials\":\"2d08086927f4d87a31154aaf0ba2e067\",\"realm\":\"
test01.ccuat.com\"},\"verb\":\"PUT\"}";
OutputStream outputStream = httpConnection.getOutputStream();
outputStream.write(input.getBytes());
outputStream.flush();
BufferedReader responseBuffer = new BufferedReader(new InputStreamReader(
(httpConnection.getInputStream())));
String output;
String result = "";
System.out.println("Output from Server:\n");
while ((output = responseBuffer.readLine()) != null) {
result = result+output;
System.out.println(output);
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}