REST API 呼び出しを介して JIRA で課題を作成したいと考えています。サンプル コードと JSON テキストを取得しました。以下のコードを実行すると、エラーは発生しませんが、JIRA で問題も発生しません。「CURL」コマンドを使用して、同じ JSON コードを使用して JIRA で問題を作成しました。しかし、以下のサンプルコードでは作成に失敗しました。誰でもこれについて助けてください。
String host = "localhost";
int port = 8080;
String userName = "admin";
String password = "admin";
DefaultHttpClient httpClient = new DefaultHttpClient();
String jsonObj = "{\"fields\":" +
"{\"project\":{\"key\": \"JAVA\"}," +
"\"summary\":\"Creating issue in JIRA.\"," +
"\"description\": \"Creating of an issue using project keys and issue type names using the REST API\", " +
"\"issuetype\": {\"name\":\"Bug\"}}}";
httpClient.getCredentialsProvider().setCredentials(new AuthScope(host, port),
new UsernamePasswordCredentials(userName, password));
HttpPost httpPost = new HttpPost("http://localhost:8080/rest/api/2/issue/");
StringEntity entity = new StringEntity(jsonObj);
entity.setContentType("application/json");
httpPost.setEntity(entity);
HttpResponse httpResponse = httpClient.execute(httpPost);
httpClient.getConnectionManager().shutdown();