所以我尝试使用JerseyJiraRestClientFactory设置对JIRA的基本HTTP调用。我有所有依赖项,现在我有这个......
public class SetUp {
public static void main(String[] args) throws Exception {
final NullProgressMonitor pm = new NullProgressMonitor();
final Console console = System.console();
if (console == null) {
System.out.println("Couldn't get Console instance");
System.exit(0);
}
String user = console.readLine("Enter your user name: ");
char[] password = console.readPassword("Enter your password: ");
char[] confirm = console.readPassword("Confirm password: ");
while (!(new String(password).equals(new String(confirm)))) {
console.printf("Error: Passwords do not match. Please Re-enter your password\n");
password = console.readPassword("Enter your password: ");
confirm = console.readPassword("Confirm password: ");
}
try {
JerseyJiraRestClientFactory f = new JerseyJiraRestClientFactory
System.out.println("\nafter 1");
JiraRestClient jc = f.createWithBasicHttpAuthentication(new URI(
"my_server"), user, new String(password));
System.out.println("\nafter 2");
Iterator<BasicProject> r = jc.getProjectClient().getAllProjects(pm).iterator();
System.out.println("\nafter 3");
int count = 0;
while (r.hasNext()) {
count++;
}
System.out.println("\nafter 4");
System.out.println("There are " + count + " issues.");
user = "";
Arrays.fill(password, ' ');
}
catch (com.atlassian.jira.rest.client.RestClientException e) {
System.out.println(e.getCause());
}
}
}
因此,在打印&#34; 2&#34;之后出现错误。我收到此错误代码
&#34;线程中的异常&#34; main&#34; com.atlassian.jira.rest.client.RestClientException:com.sun.jersey.api.client.UniformInterfaceException:客户响应状态:500&#34;
我尝试过调用不同的方法,它们都会产生相同的500.我也尝试使用有效和无效的不同登录,而且它们都是500.任何人都知道如何解决这个问题?
答案 0 :(得分:1)
HTTP代码500是“内部服务器错误”,因此与您的密码无关。 (这些应该导致类似401(未授权)或403(禁止)) 有人已在Atlassian-Forum中提出类似问题,请在此处查看:https://answers.atlassian.com/questions/263719/using-oauth-and-the-jira-java-rest-client