以下是我使用的代码:
conn = httplib.HTTPSConnection('api.projectoxford.ai')
conn.request("POST", "/vision/v1.0/ocr?%s" % params,"{'Url':'my_url_xxxxxxxxxx'}", headers_1)
response = conn.getresponse()
data = response.read()
print(data)
这是我得到的错误:
{
"code":"InvalidImageUrl",
"requestId":"3e074556-dd52-4965-b250-e821b7fb6c27",
"message":"Image URL is not accessible."
}
答案 0 :(得分:0)
您的有效负载需要正确设置:"{'url':'https://s-media-cache-ak0.pinimg.com/originals/8c/1b/82/8c1b825d2d0750957098c8a4a879d53f.jpg'}"
,请注意小写url
,而不是Url
。
答案 1 :(得分:0)
错误得到纠正。 我使用小cps'url'而不是“Url”,并将类型更改为json
headers_1 = { 'Content-Type':'application / json', 'Ocp-Apim-Subscription-Key':'*************************'#我的有效密钥 }
conn = httplib.HTTPSConnection('api.projectoxford.ai') conn.request(“POST”,“/ vision / v1.0 / impr?%s”%params,“{'url':'my_url_xxxxxxxxxx'}”,headers_1) response = conn.getresponse() data = response.read() 打印(数据)