向azure inkrecogniz发送请求

2024-05-20 19:35:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经在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"
  }
}

我做错什么了?你知道吗


Tags: keyhttpscomapijsonbaseruuri
1条回答
网友
1楼 · 发布于 2024-05-20 19:35:55

代码应该是这样的:

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))

您将需要添加到body 'language''strokes'

GIST

相关问题 更多 >