Python - You are calling a deprecated version of the Ads API

867 Views Asked by At

Seems this is a commun issue when using Facebook APIs. I am trying to use the ads API using Python. When I am testing it using the Graph API Explorer, I have the version 9.0 and I am not getting any errors. I am trying to implement the API call using Python but when I am specifiying the version 9.0, I am getting this error log:

facebook.GraphAPIError: Valid API versions are '2.8', '2.9', '2.10', '2.11', '2.12', '3.0', '3.1'

My code:

import facebook
token = "<token>"
graph = facebook.GraphAPI(access_token=token, version="9.0")
events = graph.request("?ids=<id>")
print(events)

But when I am using the version 3.1 or < than 3.1, I am getting another error:

facebook.GraphAPIError: (#2635) You are calling a deprecated version of the Ads API. Please update to the latest version: v9.0.

How can I fix it?

1

There are 1 best solutions below

0
On BEST ANSWER

Seems related to an older SDK (see the code on github)

I suggest you to update to the official Facebook SDK for Python