Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intermittent problem when calling account.createCampaign #5

Closed
roundrobin opened this issue Nov 2, 2017 · 7 comments
Closed

Intermittent problem when calling account.createCampaign #5

roundrobin opened this issue Nov 2, 2017 · 7 comments

Comments

@roundrobin
Copy link

roundrobin commented Nov 2, 2017

While 3/4 calls work, every other call I'm getting the following error message when calling account.createCampaign:

{ message: 'Unsupported post request. Object with ID \'SOME_CAMPAIGN_ID\' 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: 'DV8Huvneiyi' }

is it possible something is being cached in the background from a previous call?

Best roundrobin

For context: I'm calling the method from within a Express endpoint.

@zanyaziz
Copy link
Contributor

zanyaziz commented Nov 2, 2017

Could you forward me the exact code that you are using? I'd like to debug through it since I am not able to reproduce the issue.

@roundrobin
Copy link
Author

 account
        .createCampaign([], {
            [Campaign.Fields.name]: "Campaign name",
            [Campaign.Fields.status]: Campaign.Status.paused,
            [Campaign.Fields.objective]: "LINK_CLICKS",
            [Campaign.Fields.spend_cap]: 12000
        })
        .then(campaign => {
            console.log("integration:facebook:createdCampaign", campaign);
        });

@roundrobin
Copy link
Author

What surprises me is that the error message knows about a campaign id (SOME_CAMPAIGN_ID ) even though at this point the campaign creation didn't go through.

@roundrobin
Copy link
Author

Not sure if this helps, but here is a stack trace that is printed in the terminal.

    at FacebookRequestError.FacebookError [as constructor] (/Code/node_modules/facebook-nodejs-ads-sdk/dist/cjs.js:314:16)
    at new FacebookRequestError (/Code/node_modules/facebook-nodejs-ads-sdk/dist/cjs.js:337:129)
    at /Code/node_modules/facebook-nodejs-ads-sdk/dist/cjs.js:456:15
    at tryCatcher (/Code/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Code/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/Code/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/Code/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/Code/node_modules/bluebird/js/release/promise.js:689:18)
    at Async._drainQueue (/Code/node_modules/bluebird/js/release/async.js:133:16)
    at Async._drainQueues (/Code/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues (/Code/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:781:20)
    at tryOnImmediate (timers.js:743:5)
    at processImmediate [as _immediateCallback] (timers.js:714:5)

@roundrobin
Copy link
Author

@zanyaziz Let me know, I can also provide a lightweight example within a express.js app.

@Ivkaa
Copy link

Ivkaa commented Nov 8, 2017

@roundrobin Hey, I've got bug that acts same as you described, also the stacktrace is same. It happens when I make subsequent requests and it's because the AdAccountId (or whatever other id should be in the request url) is different (f. e. not the one I entered as argument when creating AdAccount).

Can you please check if it happens to you too?

{ error:
      { message: 'Unsupported post request. Object with ID \'12033000xxx\' 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: 'AXwvThfAkIs' } },
  method: 'POST',
  url: 'https://graph.facebook.com/v2.10/1203300xxx/ads?access_token=xxx',

@Ivkaa
Copy link

Ivkaa commented Nov 8, 2017

@zanyaziz Okay, so here you have a snippet that shows how i made it work again:
(also try to comment out the line I marked to see the error)

const { FacebookAdsApi, AdAccount, Ad, AdCreative } = require('facebook-nodejs-ads-sdk')
const config = require('../config')

const fbAdsApi = FacebookAdsApi.init(config.fb.marketingApiKey)

if (process.env.NODE_ENV !== 'production') {
  fbAdsApi.setDebug(true)
}

const fbAccount = new AdAccount('act_' + config.fb.marketingAdId)

module.exports.createAd = async function createAd(survey) {
  const adCreativeResponse = await fbAccount.createAdCreative(
    [],
    {
      [AdCreative.Fields.name]: survey.title,
      [AdCreative.Fields.title]: survey.title,
      [AdCreative.Fields.body]: survey.description,
      [AdCreative.Fields.link_url]: 'https://google.com,
      [AdCreative.Fields.object_url]: 'https://google.com',
      [AdCreative.Fields.image_url]: survey.photo.url
    }
  )

// HERE:
// this is how I set the right id and this solves the issue, I think this can help you find where the problem is
  fbAccount._data.id = 'act_' + config.fb.marketingAdId

// This second part throws error, but completely different and related to fields
  const adResponse = await fbAccount.createAd(
    [],
    {
      [Ad.Fields.name]: `Survey with title: ${survey.title}`,
      [Ad.Fields.creative]: { creative_id: adCreativeResponse.id },
      [Ad.Fields.status]: Ad.Status.paused
    }
  )

  return adResponse
}

@zanyaziz zanyaziz closed this as completed Nov 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants