facebook / facebook-ruby-business-sdk

Ruby SDK for Meta Marketing API
https://developers.facebook.com/docs/business-sdk
Other
210 stars 160 forks source link

The parameter filtering[0][operator] is required #53

Closed mailbaoer closed 6 years ago

mailbaoer commented 6 years ago

When I use filtering to find out some campaigns with ids, it said that The parameter filtering[0][operator] is required, but I confirm I have the operator params,the code is below:

ad_account.campaigns(filtering: [{"field":"id","operator":"EQUAL", "value":"23842979460490127"}]).all

how can I use the filtering correctly? Thank you very much!

euisan commented 6 years ago

You can use filtering like below.

filtering = [<FILTER_1>, <FILTER_2>, ...].to_json
ad_account.campaigns(filtering: filtering).all

=> [#<FacebookAds::Campaign {:id=> <CAMPAIGN_ID>}>, ...]
mailbaoer commented 6 years ago

🌹 thank you very much, that works! @ssankim

tmbv93 commented 5 years ago

I ran into this error as well!

I think it would be more intuitive for the library to accept an array instead of / in addition to JSON, or to check if the filtering object is JSON and raise a more descriptive error ("Receivd class Array, xpected JSON formatted string" or similar) if it isn't.