Quick start for Document Translator returns 404 error

Kacha Ano 1 Reputation point
2021-03-07T16:15:47.377+00:00

Hello,

I tried to run the document translator with the quick start following these instructions https://learn.microsoft.com/de-de/azure/cognitive-services/translator/document-translation/get-started-with-document-translation?tabs=python .
This however did not work. Running the code in post_document_request.py returned this:
response status code: 404
response status: Not Found
response headers: {'Content-Type': 'text/html', 'Server': 'Microsoft-IIS/10.0', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains', 'Date': 'Sun, 07 Mar 2021 13:25:53 GMT', 'Content-Length': '1245'}
exept for the json code I used the provided python code.

Thank you for your help
k

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

3 answers

Sort by: Most helpful
  1. Kacha Ano 1 Reputation point
    2021-03-08T12:55:04.22+00:00

    I have preview access.

    I'm a little unsure which I should put for the endpoint.
    The mistake occoured when I used the endpoint under the rider "keys and endpoint": https://api.cognitive.microsofttranslator.com/

    I also tried with this https://<NAME-OF-YOUR-RESOURCE>.cognitiveservices.azure.com/translator/text/batch/v1.0-preview.1
    in that case I recive the following error:
    response status code: 403
    response status: Forbidden
    response headers: {'Transfer-Encoding': 'chunked', 'Content-Type': 'application/json', 'X-RequestId': '800027[...]67bb', 'Set-Cookie': 'ARRAffinity=5dd610bb[...]7d2a5eff0940e;Path=/;HttpOnly;Secure;Domain=doctrans.westus.microsofttranslator.com, ARRAffinitySameSite=5dd610bbbfcdcce1e8b7e0[...]536e67d2a5eff0940e;Path=/;HttpOnly;SameSite=None;Secure;Domain=doctrans.westus.microsofttranslator.com', 'X-Powered-By': 'ASP.NET', 'apim-request-id': '88920c4b[...]b332f91127ea', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains; preload', 'x-content-type-options': 'nosniff', 'Date': 'Mon, 08 Mar 2021 12:50:24 GMT'}


  2. Tuan Nguyen 1 Reputation point
    2021-05-20T23:09:39.6+00:00

    I have the same error: 404 - Forbidden. Here's the error description:

    response status code: 403
    response status: Forbidden
    response headers: {'Transfer-Encoding': 'chunked', 'Content-Type': 'application/json', 'X-RequestId': '6bb3ff58-8601-4552-b133-43d1e0a553a3', 'Set-Cookie': 'ARRAffinity=20358cd7aa5d6b0695f01ef171fc9a95880154357830e1c6bb513b73834a2e5f;Path=/;HttpOnly;Secure;Domain=doctrans.westus.microsofttranslator.com, ARRAffinitySameSite=20358cd7aa5d6b0695f01ef171fc9a95880154357830e1c6bb513b73834a2e5f;Path=/;HttpOnly;SameSite=None;Secure;Domain=doctrans.westus.microsofttranslator.com', 'X-Powered-By': 'ASP.NET', 'apim-request-id': '6bb3ff58-8601-4552-b133-43d1e0a553a3', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains; preload', 'x-content-type-options': 'nosniff', 'Date': 'Thu, 20 May 2021 22:56:45 GMT'}

    Here's my Python code:

    import requests

    endpoint = "https://TrnDomain.cognitiveservices.azure.com/translator/text/batch/v1.0-preview.1"
    subscriptionKey = ''
    path = '/batches'
    constructed_url = endpoint + path

    payload= {
    "inputs": [
    {
    "source": {
    "sourceUrl": "https://cs2100320014388129a.blob.core.windows.net/",
    "storageSource": "AzureBlob",
    "language": "en"
    "filter":{
    "prefix": "sampleTest1",
    "suffix": ".txt"
    }

            },
            "targets": [
                {
                    "targetUrl": "https://cs2100320014388129a.blob.core.windows.net/",
                    "storageSource": "AzureBlob",
                    "category": "general",
                    "language": "fr"
                }
            ]
        }
    ]
    

    }
    headers = {
    'Ocp-Apim-Subscription-Key': subscriptionKey,
    'Content-Type': 'application/json'
    }

    response = requests.post(constructed_url, headers=headers, json=payload)

    print(f'response status code: {response.status_code}\nresponse status: {response.reason}\nresponse headers: {response.headers}')


    Appreciate any help you can provide!


  3. testUser 21 Reputation points
    2022-12-23T08:41:04.687+00:00

    The same error is reported when I use @azure-rest/ai-document-translator.
    /translator/text/batch/v1.0/batches
    /translator/text/batch/v1.0-preview.1/batches

    The first request is OK. The second request reports the error.
    273615-image.png
    Does anyone have any idea?


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.