GithubHelp home page GithubHelp logo

Comments (7)

zanyaziz avatar zanyaziz commented on April 20, 2024

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.

from facebook-nodejs-business-sdk.

roundrobin avatar roundrobin commented on April 20, 2024
 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);
        });

from facebook-nodejs-business-sdk.

roundrobin avatar roundrobin commented on April 20, 2024

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.

from facebook-nodejs-business-sdk.

roundrobin avatar roundrobin commented on April 20, 2024

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)

from facebook-nodejs-business-sdk.

roundrobin avatar roundrobin commented on April 20, 2024

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

from facebook-nodejs-business-sdk.

Ivkaa avatar Ivkaa commented on April 20, 2024

@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',

from facebook-nodejs-business-sdk.

Ivkaa avatar Ivkaa commented on April 20, 2024

@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
}

from facebook-nodejs-business-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.