Search code examples
pythonpython-3.xapiface-detection

failed API call - error 400


I've written a simple API call using requests and am getting an error 400 on executing the call. Can someone please tell me where I am going wrong? Thanks for the help. Here's the code i wrote -

 import requests

 params={
    'api_key':'gozbsSP1fxqNSS5YjcFM7qcjjKch1tBB',
    'api_secret':'HklHJCzfO87YyIC9DudGArVKJtioEhbO',
    'image_url':'http://picz.in/data/media/7/study-in-canada-students.jpg'
 }

 r = requests.post(url='https://api-
 us.faceplusplus.com/facepp/v3/detect',data=params)
 print(r)

Solution

  • 400 error code basically means it's a bad request. So it can be that you provided the wrong params for the api, or the api_key or api_secret is not correct. Check the documentation of the API whether you are sending all the required params are there or not. If so check your secret keys and make sure it's the correct one.

    Remeber to never post you API Keys on public forums like SO...