

String textToTranslate = "I would really like to drive your car around the block a few times!" String route = "/translate?api-version=3.0&from=en&to=fr&to=zu" Input and output languages are defined as parameters. Private static readonly string location = "" It can be found in the Azure portal on the Keys and Endpoint page. required if you're using a multi-service or regional (not global) resource. Private static readonly string endpoint = ""

Make sure you update the key variable with the value from your Azure portal Translator instance: Copy and paste the code sample into your application's Program.cs file. For more information, see New C# templates generate top-level statements.ĭelete the pre-existing code, including the line Console.WriteLine("Hello World!").You don't need to include top-level statements, global using directives, or implicit using directives. When you use the newer version, you only need to write the body of the Main method.The new output uses recent C# features that simplify the code you need to write.NET 6, new projects using the console template generate a new program style that differs from previous versions. The accepted value is application/json or charset=UTF-8. Optional when using a single-service global Translator Resource.Required when using a multi-service Cognitive Services or regional (geographic) resource like West US.The region where your resource was created. Your Translator service key from the Azure portal. Don't worry, we include the headers for you in the sample code for each programming language.įor more information on Translator authentication options, see the Translator v3 reference guide. To call the Translator service via the REST API, you need to include the following headers with each request. For more information on how to use the Ocp-Apim-Subscription-Region header, see Text Translator REST API headers.

The value for Ocp-Apim-Subscription-Region is the region associated with your subscription.
