因此,我尝试使用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());
        }
    }
}


因此,此错误会在打印“ 2之后”后立即消失。我收到此错误代码

“线程“主”中的异常com.atlassian.jira.rest.client.RestClientException:com.sun.jersey.api.client.UniformInterfaceException:客户端响应状态:500”

我尝试调用不同的方法,它们都导致相同的500。我还尝试使用有效和无效的不同登录名,它们都具有500。有人知道如何解决此问题吗?

最佳答案

HTTP Code 500是“内部服务器错误”,因此与您的密码无关。
(这些应该会导致出现401(Unauthorized)或403(forbidden)之类的东西)
在Atlassian论坛中已经有人问过类似的问题,请在此处查看:https://answers.atlassian.com/questions/263719/using-oauth-and-the-jira-java-rest-client

09-10 13:05
查看更多