Cognitive Service -Translator custom Endpoint Issue

RaviKumar Rajasekaran 1 Reputation point

Hi Team,

I try to access Cognitive Service Translator Service by Custom End point url.
I passed subscription key and region key in header , and i invoked valid url.
But getting the Error response "No such Host is found"


how to resolve this issue. Please advice

Azure Translator
Azure Translator
An Azure service to easily conduct machine translation with a simple REST API call.
340 questions
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
2,362 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. YutongTie-MSFT 46,091 Reputation points

    @RaviKumar Rajasekaran


    I think I have reproduced your error. In your code, you may add extra route to your request. We don't need to add any route like
    string route = "/translate?api-version=3.0&from=en&to=de&to=it";

    Please see my working code sample below:

    using System;  
    using System.Net.Http;  
    using System.Text;  
    using System.Threading.Tasks;  
    using Newtonsoft.Json; // Install Newtonsoft.Json with NuGet  
    class Program  
        private static readonly string subscriptionKey = "06658a24897740a18986a**********b88b";  
        private static readonly string endpoint = "";  
        // Add your location, also known as region. The default is global.  
        // This is required if using a Cognitive Services resource.  
        private static readonly string location = "westus2";  
        static async Task Main(string[] args)  
            // Input and output languages are defined as parameters but not add the route  
            //string route = "/translate?api-version=3.0&from=en&to=de&to=it";  
            string textToTranslate = "Hello, world!";  
            object[] body = new object[] { new { Text = textToTranslate } };  
            var requestBody = JsonConvert.SerializeObject(body);  
            using (var client = new HttpClient())  
            using (var request = new HttpRequestMessage())  
                // Build the request.  
                request.Method = HttpMethod.Post;  
                request.RequestUri = new Uri(endpoint);  
                request.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");  
                request.Headers.Add("Ocp-Apim-Subscription-Key", subscriptionKey);  
                request.Headers.Add("Ocp-Apim-Subscription-Region", location);  
                // Send the request and get response.  
                HttpResponseMessage response = await client.SendAsync(request).ConfigureAwait(false);  
                // Read response as a string.  
                string result = await response.Content.ReadAsStringAsync();  

    Hope this will help. Please let us know if any further queries.


    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
    • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators
    0 comments No comments