Отправить запрос в Azure Inkognizer - PullRequest
0 голосов
/ 02 июля 2019

Я зарегистрировался на https://azure.microsoft.com/ru-ru/try/cognitive-services

Оттуда я получил API-ключ и конечную точку https://api.cognitive.microsoft.com/inkrecognizer

Вот мой код:

import requests, json


subs_key = API_KEY
uri_base = 'https://api.cognitive.microsoft.com/inkrecognizer'
headers = {'Content-type': 'application/json',
           "Ocp-Apim-Subscription-Key": subs_key}

body = {}


response =requests.request('POST', uri_base, json=body, data=None, headers=headers)

print('Response:')
parsed =json.loads(response.text)
print(json.dumps(parsed, sort_keys=True, indent=2))

Однако, это дает мне

Response:
{
  "error": {
    "code": "404",
    "message": "Resource not found"
  }
}

Что я делаю не так?

1 Ответ

0 голосов
/ 02 июля 2019

Вот как должен выглядеть код:

import requests, json


subs_key = API_KEY
uri_base = 'https://api.cognitive.microsoft.com/inkrecognizer/v1.0-preview/recognize'
headers = {'Content-type': 'application/json',
           "Ocp-Apim-Subscription-Key": subs_key}

body = {}


response =requests.request('PUT', uri_base, json=body, data=None, headers=headers)

print('Response:')
parsed =json.loads(response.text)
print(json.dumps(parsed, sort_keys=True, indent=2))

А вам нужно будет добавить в тело 'language' и 'strokes'

GIST

...