Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to test successfully #110

Open
Lippy1m1 opened this issue Mar 2, 2023 · 6 comments
Open

Unable to test successfully #110

Lippy1m1 opened this issue Mar 2, 2023 · 6 comments

Comments

@Lippy1m1
Copy link

Lippy1m1 commented Mar 2, 2023

Every time I "Test" I receive the same result. Test failed Invalid Key, or key does not match region. I have tried two different regions with the same result. What am I doing wrong here?

image

@chriswendt1
Copy link
Member

Hi Lippy, these three need to match and come from the same resource.
image

The Text Translation Endpoint should also match the endpoint as listed in the Azure resource.

Also verify:
Are you using the newest version of the app?
Is the translation job working, only the test is failing? What are you seeing when you run a translation?

@Lippy1m1
Copy link
Author

Lippy1m1 commented Mar 2, 2023

image

So yes, I am using the three values from the translator resource. I have tried two different regions and the same thing happens with the test. I am using the latest version 0.9.3.2 and when I try to do a text translation the app bombs and closes.

@Lippy1m1
Copy link
Author

Lippy1m1 commented Mar 2, 2023

The translator resource is S1 pay as you go. My OS is Windows 11 64bit and I do have .net core 6.0.14 installed as well.

@Lippy1m1
Copy link
Author

Lippy1m1 commented Mar 6, 2023

Any ideas why I could be seeing these errors in testing and translation?

@chriswendt1
Copy link
Member

chriswendt1 commented Mar 7, 2023

I don't have an idea at this point.
Here is the code that produces the error message you are seeing when you run "Test":

       private static async Task TryCredentialsKey(string subscriptionKey, string azureRegion, string TextTransUri)
        {
            if (string.IsNullOrEmpty(TextTransUri)) TextTransUri = "https://api.cognitive.microsofttranslator.com";
            using HttpRequestMessage request = new() { Method = HttpMethod.Post, RequestUri = new Uri(TextTransUri + "/detect?api-version=3.0") };
            request.Headers.Add("Ocp-Apim-Subscription-Key", subscriptionKey);
            if (azureRegion?.ToLowerInvariant() != "global") request.Headers.Add("Ocp-Apim-Subscription-Region", azureRegion);
            request.Content = new StringContent("[{ \"Text\": \"English\" }]", Encoding.UTF8, "application/json");
            HttpClient client = new();
            HttpResponseMessage response = await client.SendAsync(request);
            if (!response.IsSuccessStatusCode)
                throw new CredentialsException("Invalid key, or key does not match region.");
        }

It does a simple language detection. If all your credentials and URLs are correct, as you expect them to be, check if a firewall or proxy blocks your access to api.cognitive.microsofttranslator.com.

@Lippy1m1
Copy link
Author

Lippy1m1 commented Mar 7, 2023 via email

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

No branches or pull requests

2 participants