Ссылочная документация от Microsoft: https://docs.microsoft.com/en-us/azure/cognitive-services/translator/quickstart-detect?pivots=programming-language-csharp
static public async Task DetectTextRequest(string subscriptionKey, string endpoint, string route, string inputText)
{
System.Object[] body = new System.Object[] { new { Text = inputText } };
var requestBody = JsonConvert.SerializeObject(body);
using (var client = new HttpClient())
using (var request = new HttpRequestMessage())
{
request.Method = HttpMethod.Post;
request.RequestUri = new Uri(endpoint + route);
request.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
request.Headers.Add("Ocp-Apim-Subscription-Key", subscriptionKey);
HttpResponseMessage response = await client.SendAsync(request).ConfigureAwait(false);
string result = await response.Content.ReadAsStringAsync();
}
}
endpoint = "https://westcentralus.api.cognitive.microsoft.com/text/analytics"
route = "/detect?api-version=3.0"
subscriptionKey = My API Key
inputText = text to be detected
Заранее спасибо!