facebook-nodejs-business-sdk icon indicating copy to clipboard operation
facebook-nodejs-business-sdk copied to clipboard

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

Open osehmathias opened this issue 2 years ago • 6 comments

Which SDK version are you using?

12.0.1

What's the issue?

The API version is 13, but the latest package version is 12.0.1

When I run it, it has the following error:

message: '(#2635) You are calling a deprecated version of the Ads API. Please update to the latest version: v13.0.',
  status: 400,
  response: {
    error: {
      message: '(#2635) You are calling a deprecated version of the Ads API. Please update to the latest version: v13.0.',
      type: 'OAuthException',
      code: 2635,
      fbtrace_id: 'AsV7oIK5LAD8BdmpaKvu0Pk'
    }
  },

osehmathias avatar Feb 26 '22 22:02 osehmathias

We have the same issue, is there any workaround?

asmarty avatar Mar 10 '22 08:03 asmarty

We have the same issue, is there any workaround?

Not that I know of - all the SDKs have this problem right now

oseh-stake avatar Mar 11 '22 23:03 oseh-stake

This is a breaking issue and needs to be critically addressed by the team / community ASAP

JayPerfetto avatar Mar 14 '22 22:03 JayPerfetto

This can be addressed by overriding the SDK API version with the following (right after you require the package):

Object.defineProperty(FacebookAdsApi, 'VERSION', { get: () => 'v13.0' });

Hope this helps the many of you in trouble with this.

vitorrd avatar Mar 23 '22 00:03 vitorrd

@vitorrd Would you mind clarifying how to apply this fix? I am not as fluent in programming jargon.

I am utilizing this SDK in Python. Wondering if I need to hardcode a fix in one of the SDKs files, or can I just add a line of code after import?

Thanks.

Edit:

To fix in Python, navigate to the file: (for me) ~\Python\Python39\Lib\site-packages\facebook_business\apiconfig.py

ads_api_config = {
  'API_VERSION': 'v14.0',
  'SDK_VERSION': 'v14.0.0',
  'STRICT_MODE': False
}

...and change both versions from 14 to 15.

Also, if you utilized the "code builder" thing they have--that supposedly creates the .py for you--there's a chance it won't work. Code was nonfunctional for me. To get anyone started who maybe in a similar situation to me, try this:

from facebook_business.adobjects.adaccount import AdAccount
from facebook_business.adobjects.adsinsights import AdsInsights
from facebook_business.api import FacebookAdsApi

access_token = '' # Put yours here
ad_account_id = '' # Put yours here
app_secret = '' # Put yours here
app_id = '' # Put yours here
FacebookAdsApi.init(access_token=access_token)

fields = [
    'impressions',
    'clicks',
    'spend',
    'ad_name',
    'adset_name',
    'campaign_name'
]
params = {
    'time_range': {'since':'2020-10-11','until':'2022-10-13'},
    'filtering': [],
    'level': 'ad'
}
print( AdAccount(ad_account_id).get_insights(
    fields=fields,
    params=params,
))

MrChadMWood avatar Oct 13 '22 22:10 MrChadMWood

This can be addressed by overriding the SDK API version with the following (right after you require the package):

Object.defineProperty(FacebookAdsApi, 'VERSION', { get: () => 'v13.0' });

Hope this helps the many of you in trouble with this.

Thank you @vitorrd your fix worked for me in node js.

import {
  Content,
  CustomData,
  DeliveryCategory,
  EventRequest,
  UserData,
  ServerEvent,
  FacebookAdsApi,
} from 'facebook-business-sdk-ts';

Object.defineProperty(FacebookAdsApi, 'VERSION', { get: () => 'v15.0' });

const FACEBOOK_PIXEL_ID = process.env.FACEBOOK_PIXEL_ID;
const FACEBOOK_PIXEL_TOKEN = process.env.FACEBOOK_PIXEL_TOKEN;

const api = FacebookAdsApi.init(FACEBOOK_PIXEL_TOKEN);

...

image

lucasoz avatar Mar 10 '23 02:03 lucasoz