Hello Roha Group,
I understand you’re receiving a 404 “page not found” error while calling the Translator API, even after adding the host entry and using a valid key. Thanks to our community volunteer for providing prompt answer.
To expand on that, I can explain why you are seeing the 404 Page Not Found error.
The Cause: API Endpoint vs. Website URL
- The URL
https://api.cognitive.microsofttranslator.com/ is the base URI for the API, not a "page" you can visit in a browser or call directly. Think of it as the main address for an office building. You are getting a 404 error because you "arrived" at the building but didn't provide a "room number" (the specific operation you want to perform).
- An API requires you to call a specific operation or route that is appended to that base URI.
- I also noticed you mentioned adding a "host entry." That is a good step for a DNS or "server not found" error, but it won't fix a
404 error, which means you did successfully find the server, but the specific "page" (or operation) you asked for doesn't exist.
The Solution: Use a Specific Operation
As the volunteer's example shows, you must call a specific operation like /translate or /detect.
A valid call must include three key pieces of information:
- The Full URL: The base URI plus the operation. Example:
https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&to=de
- Your API Key: Sent in the request header. Header:
Ocp-Apim-Subscription-Key: <YOUR_API_KEY_HERE>
- Your Region: This is often missed. The API key is tied to the Azure region where you created the resource (e.g.,
eastus, westeurope). Header: Ocp-Apim-Subscription-Region: <YOUR_REGION_HERE>
I strongly recommend you review the official Translator Text API Reference, which lists all the available operations and provides code examples for multiple languages.
Please accept and vote for the answer to help other members of the community.
Thank you for helping to improve Microsoft Q&A! 😊