【发布时间】:2016-06-22 12:29:02
【问题描述】:
以下是包含富文本/wiki 文本的 JSON 数据。我想通过 REST API 将此数据传递给 Jira 中的一个问题。 Java 是我正在使用的技术。
{"update":{"summary": [{"set": "CRF-397 – For Virgin Mobile, alert must be sent via email when Tier Mismatch exception is encountered."}]},"fields":{"description":{"set":"*Clients Impacted** Virgin Mobile *Background Information*<br>All UK schemes are experiencing at different levels some issues of:* Customers being billed on the wrong premium* Excess Fees paid at point of claim do not correspond to what has been communicated to the customer at the point of sale.* Welcome packs not being issued due to a mismatch *CRF Scope*<br>The scope of this project consists of identifying whenever a new device is communicated to Asurion by a client system and ensuring the data in each of those instances is validated to confirm that the device premium and excess fees are correctly aligned.*User Story Scope*<br>While doing enrollment if any record goes into exception due to Tier is match we have to send consolidated list of such records via email so that Asurion Team can communicate with Virgin Mobile to resolve the Tier Mismatch issues.*Requirement** An email alert must be sent when Tier Mismatch exception is encountered.* Flag based development must be done for triggering an email.* Email must be sent to Client Service, SCM and BI teams* Recipient email IDs must be configurable.* Exception list must contain below records:- * The list of devices for which there was an exception * The Feature Code sent by Virgin Mobile * The feature code configured in Client Convention for the given device*"}}}
我存储在 jiraUpdateFromBuilder 中的 JSON 之上。
我正在调用 PUT 方法来更新 Jira 中的描述,如下所示。
String _jiraUrl = applicationProperties.get(Constants.JIRAURL)
+ "/rest/api/2/issue/" + reference;
String _jiraUser = applicationProperties.get(Constants.JIRAUSER);
String _jiraPwd = applicationProperties.get(Constants.JIRAPWD);
String auth = new String(Base64.encode(_jiraUser + ":" + _jiraPwd));
int statusCode = invokePutMethod(auth, _jiraUrl.trim(),
jiraUpdateFromBuilder.toString().trim());
public static int invokePutMethod(String auth, String url, String data) {
int statusCode = 0;
try {
Client client = Client.create();
WebResource webResource = client.resource(url);
ClientResponse response = webResource
.header("Authorization", "Basic " + auth)
.type("application/json").accept("application/json")
.put(ClientResponse.class, data);
statusCode = response.getStatus();
return statusCode;
} catch (Exception e) {
Constants.ERROR.info(Level.INFO, e);
}
return statusCode;
}
这样做,我无法通过任何 REST API 更新 Jira 中的问题描述,因为这里的状态不是 201。同样的问题是 JIRA 中包含富文本的问题的所有字段。如果我需要更改 JSON 或任何其他方法,请告诉我 JRJC 是否可以提供帮助。
【问题讨论】:
-
你得到什么错误?
-
因此没有错误,但是在使用上述 json 调用 put() 方法后,我得到的状态码为 400。
标签: java json jira jira-rest-api jira-rest-java-api