Rally Software

  • 1.  Rally Api authentication

    Posted Mar 15, 2018 02:51 PM

    I use to use rally api 3.0.1 and am trying to upgrade to api 3.2.1 but the way I'm connection is looping and I can't connect to rally. So any help would be appreciated. The yellow part is the part that look

     

     Code to connect to Rally:

     

    Common.ValidateCertificate();

    RallyRestApi restApi = Common.getRestApi;

     

    Common.cs:

    public static void ValidateCertificate()

            {

                // The following code is required to connect to an on-premise Rally server without a trusted cert uploaded

                // If we remove this code it throws the following error

                // Could not establish trust relationship for the SSL/TLS secure channel".

                // This code has to placed before starting any calls to the webservise.

                TrustAllCertificatePolicy trustAll = new TrustAllCertificatePolicy();

                System.Net.ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(TrustAllCertificatePolicy.AcceptAllCerts);

            }

            public class TrustAllCertificatePolicy : ICertificatePolicy

            {

                //Default policy for certificate validation.

                public static bool DefaultValidate = false;

                public bool CheckValidationResult(ServicePoint srvPoint, X509Certificate cert, WebRequest request, int problem)

                {

                    return true;

                }

     

                public static bool AcceptAllCerts(object sender, X509Certificate cert, X509Chain chain, System.Net.Security.SslPolicyErrors SslPolicyErrors)

                {

                    return true;

                }

            }

     

    public static RallyRestApi getRestApi

            {

                //get { return _restApi;}

                get {

              

                RallyRestApi _restApi = new RallyRestApi(webServiceVersion: ReadAppSettingsValues("RallyURLVersion"));

                _restApi.Authenticate(ReadAppSettingsValues("RallyUserName"), ReadAppSettingsValues("RallyPassword"), ReadAppSettingsValues("RallyURL"),null,false);

                return _restApi;

                }

            }

            //public static RallyRestApi _restApi = new RallyRestApi(ReadAppSettingsValues("RallyUserName"), ReadAppSettingsValues("RallyPassword"), ReadAppSettingsValues("RallyURL"), ReadAppSettingsValues("RallyURLVersion"));

            public static RallyRestApi _restApi = new RallyRestApi();



  • 2.  Re: Rally Api authentication
    Best Answer

    Posted Mar 16, 2018 06:32 AM

    JonathanTorres1355981,

     

    I am not a .NET developer by any means and I am using the Mac version of Visual Studio, but if it helps, I was able to connect to an On-Premises Server using 3.1.1 and 3.2.1 with a slightly different version of what you have above.

     

    My success was using:

     

    RallyRestApi _restApi = new RallyRestApi(webServiceVersion: ReadAppSettingsValues("RallyURLVersion"));

    try
    {
       System.Net.ServicePointManager.ServerCertificateValidationCallback +=
           delegate (object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate,
               System.Security.Cryptography.X509Certificates.X509Chain chain,
               System.Net.Security.SslPolicyErrors sslPolicyErrors)
               {
                 return true; // **** Always accept
                };
       _restApi.Authenticate(ReadAppSettingsValues("RallyUserName"), ReadAppSettingsValues("RallyPassword"), ReadAppSettingsValues("RallyURL"),null,false);
     DynamicJsonObject theSub = _restApi.GetSubscription("Name");
      DynamicJsonObject theUser = _restApi.GetCurrentUser("UserName");
      Console.WriteLine("SUCCESS - Connected to Agile Central Subscription named \"" + theSub["Name"] + "\" as User " + theUser["UserName"] + ".");

    }

     

    I realize it may not be the most elegant, but since I was successful in making the connection and updates, I wanted to at least post it here.

     

    Michael



  • 3.  Re: Rally Api authentication

    Posted Mar 16, 2018 10:47 AM

    Great Thank you that seemed to work I can connect now.



  • 4.  Re: Rally Api authentication

    Posted Mar 16, 2018 11:36 AM

    Jonathan,


    Excellent!  I am glad that helped!

     

    If you would, please mark my answer as correct when you have a moment.

     

    Michael