向 azure inkrecognizer 发送请求
Send request to azure inkrecognizer
我已经在https://azure.microsoft.com/ru-ru/try/cognitive-services
注册了
从那里我得到了一个 API-key 和一个端点 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"
}
}
我做错了什么?
这里的代码应该是这样的:
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'
我已经在https://azure.microsoft.com/ru-ru/try/cognitive-services
注册了从那里我得到了一个 API-key 和一个端点 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"
}
}
我做错了什么?
这里的代码应该是这样的:
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'