Soumya Khurana
Soumya Khurana

Reputation: 63

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)

Upvotes: 2

Views: 3494

Answers (2)

gtalarico
gtalarico

Reputation: 4689

400 means its a bad request: the request you made is not what the server wanted. (invalid arguments, wrong payload data, etc)

More info on 400 errors here: https://airbrake.io/blog/http-errors/400-bad-request

The 400 Bad Request Error is an HTTP response status code that indicates that the server was unable to process the request sent by the client due to invalid syntax

Sometimes the response object will include information on why the request failed, but that's not always the case.

Upvotes: 0

memnonila
memnonila

Reputation: 359

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...

Upvotes: 2

Related Questions