【发布时间】:2016-10-28 15:37:36
【问题描述】:
我需要使用 java REST API 将用户添加到 JIRA 中的组。我需要使用组名作为查询参数和用户名作为有效负载进行 POST。我正在使用相同的 Spring RestOperations。这是我的代码:
JSONObject jsonObject = new JSONObject();
jsonObject.put("username", abc@cs.com);
Group group = restOperations.exchange(
"https://cs.jira.com/jira/rest/api/2/group/user?groupname=jira-users",
HttpMethod.POST,
new HttpEntity<>(jsonObject, getAuthorizedHttpHeaders(user, pass)),
Group.class).getBody();
我收到以下异常:
org.springframework.web.client.RestClientException: Could not write request: no suitable HttpMessageConverter found for request type [org.codehaus.jettison.json.JSONObject] and content type [application/json;charset=UTF-8]
有人可以帮我解决这个问题吗?
【问题讨论】:
标签: json post jira-rest-api