I am sending the POST request to the JIRA with my json data for create a project, but i am unable to create a project into JIRA, i tried to see the error from the Fiddler and i got following error. I am using the java.
I am posting json data from the following code, please suggest what and where i am wrong ?
public static void createTicket()throws Exception{
HttpClient client = new DefaultHttpClient();
try {
HttpPost post = new HttpPost(webPage);
Base64 b = new Base64();
String encoding = b.encodeAsString(new String("" + name + ":" + password + "").getBytes());
post.addHeader("Authorization","Basic "+encoding);
System.out.println(post.toString());
StringEntity params =new StringEntity("{'fields':{'project':{'key':'LCH-12'},'summary':'Sample issue','description':'Creating an issue via REST API','issuetype':{'name':'Bug'}}}");
post.setHeader("Content-type", "application/json");
post.setEntity(params);
HttpResponse httpResponse = client.execute(post);
System.out.println(httpResponse.toString());
}
catch(Exception e)
{
System.out.println(e);
}
finally {
httpClient.getConnectionManager().shutdown(); //Deprecated
}
}
Error Message is following:
POST http://localhost:8080/rest/api/latest/issue HTTP/1.1 [Content-Type: text/plain; charset=ISO-8859-1,Content-Length: 140,Chunked: false] HTTP/1.1 400 Bad Request [Server: Apache-Coyote/1.1, X-AREQUESTID: 585x38x1, X-ASEN: SEN-L8200978, Set-Cookie: JSESSIONID=2DFEB40B67B19BAFAFE81CF8A30B5A88; Path=/; HttpOnly, X-Seraph-LoginReason: OK, Set-Cookie: atlassian.xsrf.token=B6XG-UN93-PXWZ-FOQK|f80007dcf150dceaa1d5f561aab3d364a3598178|lin; Path=/, X-ASESSIONID: 5i51ds, X-AUSERNAME: vinuvish1, Cache-Control: no-cache, no-store, no-transform, X-Content-Type-Options: nosniff, Content-Type: application/json;charset=UTF-8, Transfer-Encoding: chunked, Date: Thu, 14 Jul 2016 04:15:23 GMT, Connection: close] org.apache.http.conn.BasicManagedEntity@4b952a2d