次のコードを実行しているときに問題に直面しています。私はrest Method DELETEとPUTを実行する同じ種類の機能も持っていますが、これらは同じ構成でうまく機能していますが、これはそうではありません。
public void Rest_POST(String cookie)
{
String urlString = "https://localhost:8443/rest/api/2/version";
HttpsURLConnection urlConnection;
String cookie = getCookie();
String JSONString = "{" +
"\"description\":\"An excellent version\"," +
"\"name\":\"New Version 54164987\"," +
"\"project\":\"zhelp\"" +
"}";
URL url;
OutputStream os;
HttpsURLConnection connection = null;
try {
//this skips the certification check
certificateManager.skipCertificateCheck();
url = new URL(urlString);
connection = (HttpsURLConnection) url.openConnection();
connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
connection.setRequestProperty("Content-Language", "en-US");
if(cookie != null) {
System.out.println("Cookie : " + cookie.split(";", 2)[0]);
connection.setRequestProperty("Cookie", cookie.split(";", 2)[0]);
}
connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setRequestProperty("Accept", "application/json");
connection.setAllowUserInteraction(true);
os = connection.getOutputStream();
System.out.println("JSONString : " + JSONString);
os.write(JSONString.getBytes());
os.flush();
System.out.println("Connection : " + connection.getURL());
}
これにより、エラー FileNotfound 例外が生成されます。
Error Message: https://localhost:8443/rest/api/2/version
Cause: java.io.FileNotFoundException: https://localhost:8443/rest/api/2/version