2012-04-18 65 views
0

我必须在JIRA中创建一个新组件 我发现POST url/rest/api/2/component用于制作新组件,但我无法知道要输入什么类型的输入。调用REST API在JIRA中创建新组件

DefaultHttpClient httpClient = new DefaultHttpClient(); 
HttpPost postRequest = new HttpPost("http://localhost:8080/rest/api/2/component/"); 

String authorization = JiraRequestResponseUtil.conversionForAuthorization(); 
postRequest.setHeader("Authorization", authorization); 

StringEntity input = new StringEntity("\"name\":\"Component 1\",\"description\":\"This is a TEST JIRA component\" ,\"leadUserName\":\"fred\",\"assigneeType\":\"PROJECT_LEAD\",\"isAssigneeTypeValid\":\"false\",\"project\":\"TEST\""); 

input.setContentType("application/json"); 
postRequest.setEntity(input); 

HttpResponse response = httpClient.execute(postRequest); 

这是我正在实施的代码。

输出我得到的失败:HTTP错误代码:400

plz帮助。

回答

0

我们不能告诉你。您需要找到您要发布的服务的文档。

0

上面的代码是正确的,只需将{ & }添加到JSON字符串。