private string PerformTranslation(string text, MSTranslationAccessToken token)
        {
            //Sitecore.Diagnostics.Log.Info("PerformTranslation: Access Token: " + token.access_token, "MSTranslationService");

            var requestUrl = string.Format(_translateUrl, HttpUtility.UrlEncode(text), this.FromLanguage, this.ToLanguage);
            var authHeader = "Bearer " + token.access_token;
            //Sitecore.Diagnostics.Log.Info("PerformTranslation: Request: " + requestUrl, "MSTranslationService");

            HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(requestUrl);

            httpWebRequest.Headers.Add("Authorization", authHeader);
            WebResponse response = null;

            try
            {
                response = httpWebRequest.GetResponse();
                using (Stream stream = response.GetResponseStream())
                {
                    DataContractSerializer serializer = new DataContractSerializer(Type.GetType("System.String"));
                    return((string)serializer.ReadObject(stream));
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                if (response != null)
                {
                    response.Close();
                }
            }
        }
        private MSTranslationAccessToken HttpPost(string DatamarketAccessUri, string requestDetails)
        {
            //Prepare OAuth request
            WebRequest webRequest = WebRequest.Create(DatamarketAccessUri);

            webRequest.ContentType = "application/x-www-form-urlencoded";
            webRequest.Method      = "POST";
            byte[] bytes = Encoding.ASCII.GetBytes(requestDetails);
            webRequest.ContentLength = bytes.Length;
            using (Stream outputStream = webRequest.GetRequestStream())
            {
                outputStream.Write(bytes, 0, bytes.Length);
            }
            using (WebResponse webResponse = webRequest.GetResponse())
            {
                DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(MSTranslationAccessToken));
                //Get deserialized object from JSON stream
                MSTranslationAccessToken token = (MSTranslationAccessToken)serializer.ReadObject(webResponse.GetResponseStream());
                return(token);
            }
        }
        private string PerformTranslation(string text, MSTranslationAccessToken token)
        {
            //Sitecore.Diagnostics.Log.Info("PerformTranslation: Access Token: " + token.access_token, "MSTranslationService");

            var requestUrl = string.Format(_translateUrl, HttpUtility.UrlEncode(text), this.FromLanguage, this.ToLanguage);
            var authHeader = "Bearer " + token.access_token;
            //Sitecore.Diagnostics.Log.Info("PerformTranslation: Request: " + requestUrl, "MSTranslationService");

            HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(requestUrl);
            httpWebRequest.Headers.Add("Authorization", authHeader);
            WebResponse response = null;
            try
            {
                response = httpWebRequest.GetResponse();
                using (Stream stream = response.GetResponseStream())
                {
                    DataContractSerializer serializer = new DataContractSerializer(Type.GetType("System.String"));
                    return (string)serializer.ReadObject(stream);
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                if (response != null)
                    response.Close();
            }
        }