【问题标题】:Microsoft Azure emotion api returns [ "statusCode": 404, "message": "Resource not found"] errorMicrosoft Azure 情感 api 返回 ["statusCode": 404, "message": "Resource not found"] 错误
【发布时间】:2017-06-24 08:34:28
【问题描述】:

我正在尝试使用 Microsoft Azure 情感 API 测试一些图像。按照microsoft 上的说明,我一直收到 { "statusCode": 404, "message": "Resource not found" } 错误。我的代码从网站修改如下:

########### Python 2.7 #############
import httplib, urllib, base64

headers = {
    # Request headers. Replace the placeholder key below with your subscription key.
    'Content-Type': 'application/json',
    'Ocp-Apim-Subscription-Key': 'key',
}

params = urllib.urlencode({ })

# Replace the example URL below with the URL of the image you want to analyze.
body = "{ 'url':'http://www.scientificamerican.com/sciam/cache/file/35391452-5457-431A-A75B859471FAB0B3.jpg' }"

try:
    # NOTE: You must use the same region in your REST call as you used to obtain your subscription keys.
    #   For example, if you obtained your subscription keys from westcentralus, replace "westus" in the 
    #   URL below with "westcentralus".
    conn = httplib.HTTPSConnection('westcentralus.api.cognitive.microsoft.com')
    conn.request("POST", "/emotion/v1.0/recognize?%s" % params, body, headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
  print("[Errno {0}] {1}".format(e.errno, e.strerror))

另外,当我在浏览器中输入端点 url,即 https://westus.api.cognitive.microsoft.com/emotion/v1.0 时,它显示 { "error": { "code": "ResourceNotFound", "message": "resource not found." } }。我不确定这是否与错误有关。

有没有人遇到过这个问题,或者有人可以给我一些解决问题的建议吗?谢谢!

【问题讨论】:

  • 这个问题你解决了吗=?

标签: python azure computer-vision


【解决方案1】:

无论您收到什么状态代码和错误消息,我也遇到过同样的问题

[消息:受保护] => 失败: 代码:404 值:未找到 详细信息(如果有):未找到段“工作”的资源..

检查您的参数,如果您要传递到已处理 JobId 和所有内容的天蓝色。然后你会得到这个问题。您需要交叉检查您传递的文件信息是否已经处理。

谢谢!

【讨论】:

    【解决方案2】:

    我尝试重现您的问题成功,是westcentralus主机不存在引起的,如下。

    请将您的代码中的主机westcentralus.api.cognitive.microsoft.com 更改为westus.api.cognitive.microsoft.com,然后它就可以工作了。

    【讨论】:

      猜你喜欢
      • 2019-05-12
      • 2023-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-04
      • 1970-01-01
      • 2020-01-28
      • 1970-01-01
      相关资源
      最近更新 更多