I want to create an issue in JIRA via REST API call. I got a sample code and JSON text. When I executed the below code there is no error, but also no issue is created in JIRA. I have used the same JSON code to create issue in JIRA with "CURL" command. But I failed to create with this sample code below. Anyone please help on this.
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();