Sample code doesnt run: "You are calling a deprecated version of the Ads API. Please update to the latest version: v14.0."
Which SDK version are you using?
Im using the facebook-nodejs-business-sdk version 13.0.0
What's the issue?
The issue is that I can not run the Sample code given to me by Facebook because my version (13.0.0) is not supported anymore. The problem is that I cant update the "facebook-nodejs-business-sdk" to 14.0 because the npm package doesn't exist.
Steps/Sample code to reproduce the issue
This is the sample code given to me by Facebook
const bizSdk = require("facebook-nodejs-business-sdk");
const AdAccount = bizSdk.AdAccount;
const AdsInsights = bizSdk.AdsInsights;
let access_token = "ACCESS_TOKEN";
let ad_account_id = "act_ID";
let app_secret = "APP_SECRET";
let app_id = "APP_ID";
const api = bizSdk.FacebookAdsApi.init(access_token);
const account = new AdAccount(ad_account_id);
const showDebugingInfo = true; // Setting this to true shows more debugging info.
if (showDebugingInfo) {
api.setDebug(true);
}
let ads_insights;
let ads_insights_id;
const logApiCallResult = (apiCallName, data) => {
console.log(apiCallName);
if (showDebugingInfo) {
console.log("Data:" + JSON.stringify(data));
}
};
const fields = [MY_FIELDS];
const params = {
time_range: { since: "2022-05-03", until: "2022-06-02" },
filtering: [],
level: "ad",
breakdowns: [],
};
new AdAccount(ad_account_id)
.getInsights(fields, params)
.then((result) => {
logApiCallResult("ads_insights api call complete.", result);
ads_insights_id = result[0].id;
})
.catch((error) => {
console.log(error);
});
Observed Results:
And this is the output I got:
message: '(#2635) You are calling a deprecated version of the Ads API. Please update to the latest version: v14.0.',
status: 400,
response: {
error: {
message: '(#2635) You are calling a deprecated version of the Ads API. Please update to the latest version: v14.0.',
type: 'OAuthException',
code: 2635,
fbtrace_id: 'TRACE_ID'
}
},`
Expected Results:
I expected the Sample code to work and provide me with the correct output.
I believe the issue is that the API URL I'm using ("https://graph.facebook.com/v13.0/act_....") contains v.13. But how do I change that? The npm package for v.14 does not exist as far as I know.
Up
I'm facing the same issue too, I'm running the exact sample code Meta provides through the Marketing Api.
Hi, Meta alive?
Same problem. I assume there's some lag between API updates and SDK updates? However, would be great to know what that wait time is.
Please upgrade quickly🚀, thanks🎉
same issue here
you can try this temporary solution
const bizSdk = require('facebook-nodejs-business-sdk');
Object.defineProperty(bizSdk.FacebookAdsApi, 'VERSION', { get: () => 'v15.0' });
Object.defineProperty(bizSdk.FacebookAdsApi, 'SDK_VERSION', { get: () => 'v15.0.0' });