facebook / facebook-python-business-sdk

Python SDK for Meta Marketing APIs
https://developers.facebook.com/docs/business-sdk
Other
1.29k stars 636 forks source link

Error to create a lookalike audience in facebook api (#2654) #472

Closed cyib closed 6 years ago

cyib commented 6 years ago

(#2654) Type Mismatch: The type integer is expected but a type NULL was received with value.

I really do not know what's incompatible, in my code I'm making a post request using axios and theoretically I'm passing everything I need to make a lookalike audience:

...

app.post('/lookalike', function (req, res) {
  var body = JSON.parse(JSON.stringify(req.body));
  var url = 'https://graph.facebook.com/v3.0/' + body.adaccountid + '/customaudiences';
  var lookalike = JSON.parse(body.lookalike);
  axios.post(url,
    {
      name: lookalike.name,
      subtype: lookalike.subtype,
      origin_audience_id: lookalike.origin_audience_id,
      lookalike_spec: JSON.stringify(lookalike.lookalike_spec),
      access_token: body.token
    }).then(resp => {
      console.log(resp);
      res.status(200).send('OK');
    }).catch(error => { 
      console.log(error); 
      res.status(200).send(error.response.data.error.message);
    });

});

...

I'm using Node.JS as a server! anyone know what is missing?

ellentao commented 6 years ago

Hi,

Thanks for your comment. There is a break change change for custom audience creation in v3.0. The change log is here: https://developers.facebook.com/docs/graph-api/changelog/version3.0 (search for Audiences and Ads Targeting under "breaking changes").

You can still use the old audience rule syntax in previous API versions (<3.0). If you want to use the new version, here are some examples: https://developers.facebook.com/docs/marketing-api/audiences-api/websites#audiencerules.

If you believe it's a bug in API, you could report it on developer site https://developers.facebook.com/support/bugs/. Thanks!