0

I am trying to make the Kairos example code for enroll (http://docs.kairosv1.apiary.io/#reference/face-recognition/enroll/post) work on my home computer, but it gives me this error:

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

Here is my code:

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

Thanks in advance!

Daniel Lewis
  • 88
  • 2
  • 9
  • Error 403 is a permission error. Do you have to provide log-in credentials to that site? You can create a [`Session`](http://docs.python-requests.org/en/latest/user/advanced/#session-objects) with your credentials before making your `Request` – Cory Kramer Jul 02 '17 at 13:26
  • @CoryKramer I tried it with my own pictures on my website, and got the same error. I checked that it was accessible by everyone without credentials too. – Daniel Lewis Jul 02 '17 at 13:30

1 Answers1

0
  1. Add more info to your header
  2. Use python 3

For more details, please check this post: urllib2.HTTPError: HTTP Error 403: Forbidden

FullStackDeveloper
  • 910
  • 1
  • 16
  • 40