本文介绍了获取结果中的Rally身份验证问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用asp.net MVC应用程序并使用Rally Web API进行集成.我想从集会站点获取数据.

I am using asp.net MVC application and consuming Rally web API for integration. I want fetch the data from rally site.

            RallyRestApi restApi = new RallyRestApi(webServiceVersion: "v2.0");
            dynamic authenticateUser=restApi.Authenticate(usr.UserName, usr.Password, "https://rally1.rallydev.com/", allowSSO: false);
            dynamic objUserName;
            if (authenticateUser.ToString().ToLower() == "authenticated")
            {
                Session["Username"] = usr.UserName;
                Session["Password"] = usr.Password;                   
                FormsAuthentication.SetAuthCookie(usr.UserName, true);
                FormsAuthentication.SetAuthCookie(usr.Password, true);
                objUserName = restApi.GetCurrentUser();
                Session["DisplayName"] = objUserName["DisplayName"];
                return RedirectToAction("Home", "PortfolioItem");
            }

此处身份验证成功.但是根据我的研究,如果我们想每次都获取数据,我认为我们需要传递如下的用户身份验证详细信息:

Here Authentication is successful. But as per my research, if we want to fetch data every time, I think we need to pass user authentication details like below:

      CreateResult createResult = restApi.Create("defect", toCreate); // need to get with same restApi object or authentication details


      OperationResult updateResult = restApi.Update(createResult.Reference, toUpdate);

      //Get the item
      DynamicJsonObject item = restApi.GetByReference(createResult.Reference);// need to get with same restApi object or authentication details

      //Query for items
      Request request = new Request("defect");
      request.Fetch = new List<string>() { "Name", "Description", "FormattedID" };
      request.Query = new Query("Name", Query.Operator.Equals, "My Defect");
      QueryResult queryResult = restApi.Query(request); // need to get with same restApi object or authentication details

像上面一样,是否需要获取任何东西,是否需要每次都进行身份验证?请对此进行澄清.

Like above, is it if we need to fetch anything, we need to authenticate first and every time? please clarify on this.

推荐答案

您需要为您创建的每个RallyRestApi实例进行一次身份验证.通常,最好先创建一个,然后使用它,然后再对其进行处理,而不是一次创建然后将其永久保留在会话中.

You'll need to authenticate once for each instance of RallyRestApi you create. In general it is better to create one, use it, and then dispose of it rather than creating it once and then keeping it around in session forever.

这篇关于获取结果中的Rally身份验证问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-24 12:50