Microsoft Translator receiving error 405000, "The request method is not supported for the requested resource."

Neale Faunt 26 Reputation points
2021-05-08T12:47:42.037+00:00

I'm receiving this error using C# module that had previously been working for months. Using the following endpoint:

https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&from=en&to=zh-Hans" -H "Ocp-Apim-Subscription-Key: <client-secret>" -H "Content-Type: application/json; charset=UTF-8" -d "[{'Text':'Hello, what is your name?'}]

Resource is global on paid Azure subscriptions. I regenerated the keys within Azure and inserted as the new key. Did something change that resulted in this not working?

Azure AI Translator
Azure AI Translator
An Azure service to easily conduct machine translation with a simple REST API call.
488 questions
{count} votes

Accepted answer
  1. svijay-MSFT 5,256 Reputation points Microsoft Employee Moderator
    2021-05-12T13:01:59.53+00:00

    The powershell error looked more like a network error. So I had suggested running the below command :

    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12  
     $headers = @{"Ocp-Apim-Subscription-Key" = "<Your Subscription key>";"Content-Type"= "application/json";"charset"="UTF-8"}  
     $response = Invoke-WebRequest -Uri "https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&from=en&to=zh-Hans" -Headers $headers -Body "[{'Text':'Hello, what is your name?'}]" -Method Post   
    

    The code [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 enforces to make use of the TLS 1.2. As mentioned in this article, Cognitive Services endpoints exposed over HTTP enforce TLS 1.2.

    Translated code ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; helped you to resolve your Issue.

    ----------------------

    Please do not forget to "Accept the answer" wherever the information provided helps you. This will help others in the community as well.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.