Rally Authentication issue in Getting results

天大地大妈咪最大 提交于 2019-12-11 05:17:00

问题


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

in Login Controller

            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.


回答1:


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.



来源:https://stackoverflow.com/questions/42346253/rally-authentication-issue-in-getting-results

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!