Пока я могу установить соединение только с Джирой, но я не знаю, как мне получить определенные поля.Из того, что я понимаю, класс SearchResult JIRA API должен решить эту проблему, но я не знаю, как интегрировать его в мой существующий код.Любая помощь могла бы быть полезна.
Java-версия - 8, ОС - Windows 10, Eclipse - Mars
/ * Использованные банки: jersey-bundle-1.9.jar (https://mvnrepository.com/artifact/com.sun.jersey/jersey-bundle/1.9) javax.ws.rs-api-2.0-m02.jar (https://mvnrepository.com/artifact/javax.ws.rs/javax.ws.rs-api/2.0-m02) * /
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.core.util.Base64;
public class JiraData {
static ClientResponse response;
public static void main(String[] args) {
try
{
String auth = new String(Base64.encode("username" + ":" + "password"));
final String headerAuthorization = "Authorization";
final String headerAuthorizationValue = "Basic " + auth;
final String headerType = "application/json";
Client c = Client.create();
WebResource webResource = c.resource("https://jira.com");
response = webResource.header(headerAuthorization, headerAuthorizationValue).type(headerType).accept(headerType).get(ClientResponse.class);
String connectionresult = response.toString();
System.out.println(connectionresult); // returned a response status of 200 OK
if (response.getResponseStatus() != null && response.getResponseStatus().getStatusCode() == 200)
{
System.out.println("Connection Successful");
fetchFields();
}
}
catch(Exception e)
{
System.out.println(" Connection Error " + e);
}
}
private static void fetchFields() {
try
{
String jql = "project = SAMPLE";
/*
* Missing logic to Capture Jira fields like Ticket Number, Ticket URL, Issue Type, Ticket Status for project passed in jql
*/
}
catch(Exception e)
{
System.out.println(" Error from fetchFields method " + e);
}
finally
{
response.close();
}
}
}