试图通过java中的Rally API创建/更新/删除/查询Rally时获取HTTP/1.1 401未经授权的异常

试图通过java中的Rally API创建/更新/删除/查询Rally时获取HTTP/1.1 401未经授权的异常,java,api,rally,http-status-code-401,unauthorized,Java,Api,Rally,Http Status Code 401,Unauthorized,试图通过java中的Rally API创建/更新/删除/查询Rally时获取HTTP/1.1 401未经授权的异常 // Create and configure a new instance of RallyRestApi RallyRestApi restApi = new RallyRestApi(new URI("https://rally1.rallydev.com"),"sphoortix.patil@foo.com", "Foo@123"); restApi.set

试图通过java中的Rally API创建/更新/删除/查询Rally时获取HTTP/1.1 401未经授权的异常

// Create and configure a new instance of RallyRestApi
    RallyRestApi restApi = new RallyRestApi(new URI("https://rally1.rallydev.com"),"sphoortix.patil@foo.com", "Foo@123");
    restApi.setWsapiVersion("v2.0");
    restApi.setApplicationName("Add Test Case Result");


    //Query User
    QueryRequest userRequest = new QueryRequest("User");
    String workSpace = userRequest.getWorkspace();
    userRequest.setFetch(new Fetch("UserName", "Subscription", "DisplayName"));
    userRequest.setQueryFilter(new QueryFilter("UserName", "=", "sphoortix.patil@foo.com"));
    QueryResponse userQueryResponse = restApi.query(userRequest);
    JsonArray userQueryResults = userQueryResponse.getResults();
    JsonElement userQueryElement = userQueryResults.get(0);
    JsonObject userQueryObject = userQueryElement.getAsJsonObject();
    String userRef = userQueryObject.get("_ref").getAsString();

    // Query for Test Case to which we want to add results
    QueryRequest testCaseRequest = new QueryRequest("TestCase");
    testCaseRequest.setFetch(new Fetch("FormattedID","Name"));
    testCaseRequest.setQueryFilter(new QueryFilter("FormattedID", "=", "TC1147"));
    QueryResponse testCaseQueryResponse = restApi.query(testCaseRequest);
    JsonObject testCaseJsonObject = testCaseQueryResponse.getResults().get(0).getAsJsonObject();
    String testCaseRef = testCaseQueryResponse.getResults().get(0).getAsJsonObject().get("_ref").getAsString();
我在线程“main”java.io.IOException:HTTP/1.1 401 Unauthorized中得到
异常

每次重新启动时出现异常。获取
restapi.create
restapi.query

我不知道可能是什么问题,我认为这一定是由于SSO问题,并且还发现消息来源说,当您试图通过Rally API进行操作时,Rally API需要一个安全令牌。指


请提供指导/帮助。

Rally的SDK工具包还不支持SSO。如果您的组织使用SSO,您需要让Rally管理员将您的用户ID添加到白名单中,以便您可以使用/或SSO/Rally凭据

请注意,JavaREST工具包将为您处理所有的身份验证令牌管理,因此您无需担心获取或维护API身份验证密钥。java工具包可以为您做到这一点

最后一种可能是您和Rally之间有一个代理服务器。如果是这种情况,您可以通过以下方式配置代理:

restApi.setProxy(新URI(proxyserver))