I’m creating an app that needs to display Facebook marketing data such as insights, cpm, etc on various pages and posts associated with an account. I haven’t been able to figure it out so far. I’ve created an app, and have tried making calls from the sandbox account with the appropriate access token. When running the demo code to read the ad account’s name and age I am getting the following error. This has been really frustrating and my employer is getting mad. Any help is appreciated.
Code (node.js):
const adsSdk = require('facebook-nodejs-ads-sdk');
const accessToken = 'Sandbox acct token';
const api = adsSdk.FacebookAdsApi.init(accessToken);
const AdAccount = adsSdk.AdAccount;
const account = new AdAccount(XX Sandbox ID XX);
console.log(account.id)
account
.read([AdAccount.Fields.name, AdAccount.Fields.age])
.then((account) => {
logPassedTest(test1 + ':Pass', account);
})
.catch((error) => {
console.log(error);
});
Error:
message: 'Unsupported get request. Object with ID 'XXX' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api',
{ error:
{ message: 'Unsupported get request. Object with ID 'XXX' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api',
type: 'GraphMethodException',
code: 100,
error_subcode: 33,
fbtrace_id: 'ACp+q8Bas3Z' } },
method: 'GET',
url: 'https://graph.facebook.com/v2.11/X?fields=name%2Cage&access_token=XX',
data: {} }
2
Answers
The AdAccount ID is prefixed with
act_
i.e.
act_<ACCOUNT_ID>
.There is really no way of debugging this. The error code likely means you are providing the wrong object to the call you are making.
Go to: https://developers.facebook.com/tools/explorer/
Plug in your access token and the exact call you are making. If the call fails, remove pieces of it until it succeeds.