Skip to content

translation API doesn't work in python2.7? #1

Open

Description

@yangpancn

I am developing an web App that calls the Text Translation API. My whole project is developed in Python2.7 so I try to call the APIs in Python2.7. But I always get the failure result:

send: 'POST /translate?api-version=3.0&to=zh HTTP/1.1\r\nHost: api.cognitive.microsofttranslator.com\r\nAccept-Encoding: identity\r\nContent-Length: 19\r\nOcp-Apim-Subscription-Key: [my-sub-key]\r\nContent-type: application/json\r\nX-ClientTraceId: 7ade7c69-7100-4afb-8bb7-676d594637c4\r\n\r\n'
send: '[{"Text": "Hello"}]'
DEBUG:root:
reply: 'HTTP/1.1 404 Not Found\r\n'

My code is in https://github.com/yangpancn/alchemy/blob/master/ms_translator.py

could someone provide a demo code how to use the API in python2.7?
Thanks in advance!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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