Ejemplo n.º 1
0
        public static HttpClient GetHttpClient()
        {
            string url      = "https://cggtech.crm.dynamics.com";
            string username = "******";
            string password = "******";
            string clientId = "fe4c5bad-24a7-433a-a523-318a435ad676";
            string version  = "v9.1";

            try
            {
                HttpMessageHandler messageHandler;
                messageHandler = new OAuthMessageHandler(url, clientId, username, password, new HttpClientHandler());

                HttpClient httpClient = new HttpClient(messageHandler)
                {
                    BaseAddress = new Uri(string.Format("{0}/api/data/{1}/", url, version)),
                    Timeout     = new TimeSpan(0, 2, 0), // 2 minutes
                };

                return(httpClient);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public static HttpClient GetHttpClient()
        {
            string url      = "https://ryantest12345.crm.dynamics.com";
            string username = "******";
            string password = "******";
            string clientId = "d2bff45d-5dba-4f19-8841-d8d979eb6dab";
            string version  = "v9.1";

            try
            {
                HttpMessageHandler messageHandler;

                messageHandler = new OAuthMessageHandler(url, clientId, username, password, new HttpClientHandler());

                HttpClient httpClient = new HttpClient(messageHandler)
                {
                    BaseAddress = new Uri(string.Format("{0}/api/data/{1}/", url, version)),
                    Timeout     = new TimeSpan(0, 2, 0),
                };

                return(httpClient);
            }
            catch (Exception)
            {
                throw;
            }
        }