Kairos人脸识别 - Python 2:当我尝试上传照片时收到403 Forbidden错误

时间:2017-07-02 13:21:07

标签: python http face-recognition

我正在尝试将Kairos示例代码(http://docs.kairosv1.apiary.io/#reference/face-recognition/enroll/post)用于我的家庭计算机,但它给了我这个错误:

File "C:\Python27\lib\urllib2.py", line 556, in http_error_default
  raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 403: Forbidden

这是我的代码:

from urllib2 import Request, urlopen

values = """
  {
    "image": "http://media.kairos.com/kairos-elizabeth.jpg",
    "subject_id": "Elizabeth",
    "gallery_name": "MyGallery"
  }
"""

headers = {
  'Content-Type': 'application/json',
  'app_id': 'd0dd238e',
  'app_key': 'f4828ade9a868af6365d982e5822f2d1s'
}
request = Request('https://api.kairos.com/enroll', data=values, headers=headers)

response_body = urlopen(request).read()
print response_body

提前致谢!

1 个答案:

答案 0 :(得分:0)

  1. 在标题中添加更多信息
  2. 使用python 3
  3. 有关详细信息,请查看此帖:urllib2.HTTPError: HTTP Error 403: Forbidden