Skip to content
This repository has been archived by the owner on Nov 8, 2021. It is now read-only.

Getting - {"error":{"code":"404","message": "Resource not found"}} #54

Open
avinashsingh9 opened this issue Nov 9, 2020 · 1 comment

Comments

@avinashsingh9
Copy link

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;
        }
    }
}
@avinashsingh9
Copy link
Author

avinashsingh9 commented Nov 10, 2020

Please provide the solution ASAP.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant