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

No create method for AdSet #74

Closed mtam2 closed 4 years ago

mtam2 commented 5 years ago

Which SDK version are you using?

Ruby 2.6.0 facebookbusiness gem from versions 0.3.3.3 to 0.4.0.1

What's the issue?

In versions >0.3.3.2, FacebookAds::AdAccount.get("XXX").adsets has lost the create method. This example to create an AdSet does not work as a result: https://github.com/facebook/facebook-ruby-business-sdk/blob/master/examples/AdAccountAdSetsPostCreateAdSet.rb

Steps/Sample code to reproduce the issue

Observed Results:

Current traceback

$ gem uninstall facebookbusiness -s
$ gem install facebookbusiness -v 0.4.0.1
$ irb
2.6.0 :001 > require 'facebookbusiness'
 => true 
2.6.0 :002 > act = FacebookAds::AdAccount.get("act_XXXXXXXXXXXXXXXX")
 => #<FacebookAds::AdAccount {:id=>"act_XXXXXXXXXXXXXXXX"}> 
2.6.0 :003 > act.adsets.create({})
Traceback (most recent call last):
        4: from /home/mtamdev/.rvm/rubies/ruby-2.6.0/bin/irb:23:in `<main>'
        3: from /home/mtamdev/.rvm/rubies/ruby-2.6.0/bin/irb:23:in `load'
        2: from /home/mtamdev/.rvm/rubies/ruby-2.6.0/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>'
        1: from (irb):3
NoMethodError (undefined method `create' for #<#<Class:0x00007fffbc0d4e40>:0x00007fffbc3c51b8>)

Expected Results:

Intended traceback

$ gem uninstall facebookbusiness -s
$ gem install facebookbusiness -v 0.3.3.2
$ irb
2.6.0 :001 > require 'facebookbusiness'
 => true
2.6.0 :002 > act = FacebookAds::AdAccount.get("act_XXXXXXXXXXXXXXXX")
 => #<FacebookAds::AdAccount {:id=>"act_XXXXXXXXXXXXXXXX"}>
2.6.0 :003 > act.adsets.create({})
  Traceback (most recent call last):
    9: from /home/mtamdev/.rvm/rubies/ruby-2.6.0/bin/irb:23:in `<main>'
    8: from /home/mtamdev/.rvm/rubies/ruby-2.6.0/bin/irb:23:in `load'
    7: from /home/mtamdev/.rvm/rubies/ruby-2.6.0/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>'
    6: from (irb):3
    5: from /home/mtamdev/.rvm/gems/ruby-2.6.0@dataclover-core/gems/facebookbusiness-0.3.3.2/lib/facebook_ads/edge.rb:95:in `create'
    4: from /home/mtamdev/.rvm/gems/ruby-2.6.0@dataclover-core/gems/facebookbusiness-0.3.3.2/lib/facebook_ads/ad_object.rb:132:in `block (2 levels) in <class:AdObject>'
    3: from /home/mtamdev/.rvm/gems/ruby-2.6.0@dataclover-core/gems/facebookbusiness-0.3.3.2/lib/facebook_ads/api_request.rb:48:in `execute'
    2: from /home/mtamdev/.rvm/gems/ruby-2.6.0@dataclover-core/gems/facebookbusiness-0.3.3.2/lib/facebook_ads/api_request.rb:53:in `execute_now'
    1: from /home/mtamdev/.rvm/gems/ruby-2.6.0@dataclover-core/gems/facebookbusiness-0.3.3.2/lib/facebook_ads/api_request.rb:67:in `create_response'
FacebookAds::ClientError (Invalid parameter: Required Field Is Missing (fbtrace_id: A7woqYlpigEe5jPHM0rA_nw))
mtam2 commented 5 years ago

https://github.com/facebook/facebook-ruby-business-sdk/commit/4382861c5d2c205d4af9fb2d31f0d4105f118bde#diff-c81ec6a2f566828f60cc0ebba678537bL473 Y'all changed it to ad_sets from adsets. Please update the all examples accordingly.

Galaxy83 commented 5 years ago

Just waisted 3 hours on this!

Not only it's ad_sets.create, if you need to fetch Ad Sets, you need to change it back to adsets

stale[bot] commented 4 years ago

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.

mtam2 commented 4 years ago

Examples still use old deprecated syntax for retrieving an ad_account's adsets. https://github.com/facebook/facebook-ruby-business-sdk/blob/master/examples/AdAccountAdSetsPostCreateAdSet.rb#L32

mtam2 commented 4 years ago

Update: the class is now back to ad_account.adsets without the underscore. It only took 3 months but this is back to normal and anyone who is using this gem after 2020-04-01 with version v0.6.0.2 should use adset and NOT ad_set.