facebook / facebook-python-business-sdk

Python SDK for Meta Marketing APIs
https://developers.facebook.com/docs/business-sdk
Other
1.31k stars 642 forks source link

Deprecated Version #512

Closed vnportnoy closed 6 years ago

vnportnoy commented 6 years ago

I am getting this error when trying to do any request (used to work until a few days ago).

You are calling a deprecated version of the Ads API. Please update to the latest version: v3.0.

Message: Call was not successful Method: GET Path: https://graph.facebook.com/v2.11/act_1394270470695081/insights Params: {'fields': 'campaign_id,campaign_name,actions,impressions,spend', 'level': 'campaign', 'date_preset': 'yesterday'}

Status: 400 Response: { "error": { "message": "(#2635) You are calling a deprecated version of the Ads API. Please update to the latest version: v3.0.", "type": "OAuthException", "fbtrace_id": "GR2g3Shc/Rd", "code": 2635 } }

jingping2015 commented 6 years ago

You should call api v3.0/v3.1 to solve your problem.

vnportnoy commented 6 years ago

How? I never set that on code.

On Fri, 17 Aug 2018 at 15:33 Jing Ping notifications@github.com wrote:

You should call api v3.0/v3.1 to solve your problem.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/facebook/facebook-python-business-sdk/issues/512#issuecomment-413952728, or mute the thread https://github.com/notifications/unsubscribe-auth/ADwpKv-0bw9HQNHF6w9gHa_5s_3moAlpks5uRwxpgaJpZM4WB-dF .

brandonkane commented 6 years ago

@vnportnoy Just upgrade your python package:

pip install facebook_business --upgrade

Facebook turns off old versions of the SDK a few months after the new versions are released to make sure everyone is on the latest version. You can see the dates and versions here under "Marketing API Changelog"

bennicholes commented 6 years ago

I have the same exact problem and I have updated via pip

 ❯ pip3 install facebook_business                                                                                                                             [17:53:16]
Collecting facebook_business
Requirement already satisfied: six>=1.7.3 in /usr/local/lib/python3.6/site-packages (from facebook_business) (1.11.0)
Requirement already satisfied: requests>=2.3.0 in /usr/local/lib/python3.6/site-packages (from facebook_business) (2.18.4)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/site-packages (from requests>=2.3.0->facebook_business) (2017.11.5)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.6/site-packages (from requests>=2.3.0->facebook_business) (3.0.4)
Requirement already satisfied: urllib3<1.23,>=1.21.1 in /usr/local/lib/python3.6/site-packages (from requests>=2.3.0->facebook_business) (1.22)
Requirement already satisfied: idna<2.7,>=2.5 in /usr/local/lib/python3.6/site-packages (from requests>=2.3.0->facebook_business) (2.6)
Installing collected packages: facebook-business
Successfully installed facebook-business-3.1.2

 bnicholes@macbookpro14  ~/Desktop 
 ❯ python3 face.py                                                                                                                                            [17:53:27]
Traceback (most recent call last):
  File "face.py", line 20, in <module>
    audience = ad_account.create_custom_audience(params=params)
  File "/usr/local/lib/python3.6/site-packages/facebookads/adobjects/adaccount.py", line 1445, in create_custom_audience
    return request.execute()
  File "/usr/local/lib/python3.6/site-packages/facebookads/api.py", line 674, in execute
    api_version=self._api_version,
  File "/usr/local/lib/python3.6/site-packages/facebookads/api.py", line 332, in call
    raise fb_response.error()
facebookads.exceptions.FacebookRequestError:

  Message: Call was not successful
  Method:  POST
  Path:    https://graph.facebook.com/v2.11/act_1724169617634172/customaudiences
  Params:  {'subtype': 'CUSTOM', 'name': 'test', 'description': 'Bombora Direct Audience Injection'}

  Status:  400
  Response:
    {
      "error": {
        "message": "(#2635) You are calling a deprecated version of the Ads API. Please update to the latest version: v3.0.",
        "type": "OAuthException",
        "code": 2635,
        "fbtrace_id": "E7QVzE3VaAi"
      }
    }
arorasudhir commented 6 years ago

It looks like you are using facebookads. try this change from facebookads.api import FacebookAdsApi to from facebook_business.api import FacebookAdsApi

STANAPI commented 6 years ago

I'm also receiving the same error. Tried all the steps above, still not working

arorasudhir commented 6 years ago

pip uninstall facebookads pip install facebook_business

jbb231 commented 6 years ago

Changing from facebookads to facebook_business package, because of the API upgrade v2.12 to v3.1, I get this:

from facebook_business.adobjects.ad import Ad
facebook_business.apiconfig.ads_api_config = {
  'API_VERSION': 'v3.0',
  'SDK_VERSION': 'v2018.7.31',
  'STRICT_MODE': False} 

data = Ad(ad_id).get_insights(
                            fields=metrics,
                            params=params)

ERROR Could not find a suitable TLS CA certificate bundle, invalid path: C:\Users****\AppData\Local\Temp_MEI233242\facebook_business\fb_ca_chain_bundle.crt

Do you know what can I do? Thanks.

apurvis commented 6 years ago

@jbb231 you probably need to somehow upgrade SSH - in the past few years a lot of auth has become less accepting of the old version of TLS. unfortunately if you're on windows i can't really offer any help on how to actually do that..

jingping2015 commented 6 years ago

Since we want to handle bugs more efficiently, we've decided to close issue reporting in Github and move to our dedicated bug reporting channel. If you encounter a bug with Business SDK (Python), please report the issue at our developer bug reporting channel.