Cognitive-Face-iOS
Cognitive-Face-iOS copied to clipboard
Getting - {"error":{"code":"404","message": "Resource not found"}}
Hi I've been trying to implement the translator API, I started the API service on my Azure account and already got the subscription keys, but I haven't been able to get this to work!
As a response, I am getting a Message - "{"error":{"code":"404","message": "Resource not found"}}" Using Below Code: public static class AzureTranslator { private static readonly string subscriptionKey = "I am using generated key"; private static readonly string endpoint = "I am using generated endpoint"; private static readonly string location = "eastus"; public static async Task FunctionResult() { string route = "/translate?api-version=3.0&to=de"; string textToTranslate = "Hello, world!"; object[] body = new object[] { new { Text = textToTranslate } }; //var requestBody = JsonConvert.SerializeObject(ds.Tables[0]); 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 + route);
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();
string result = await response.Content.ReadAsStringAsync();
//return result;
}
}
}
Please provide the solution ASAP.