Skip to content

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

@yangpancn

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!

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