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

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

Open
@avinashsingh9

Description

@avinashsingh9

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;
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions