facebook / facebook-ruby-business-sdk

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

`ad_account.adrules_library.first.evaluation_spec` raises JSON::ParserError #177

Open tdutreui-solocal opened 2 years ago

tdutreui-solocal commented 2 years ago

Which SDK version are you using?

facebookbusiness (0.13.0.0)

What's the issue?

After successfully creating an Adrule, you cannot fetch it's evaluation_spec : ad_account.adrules_library.first.evaluation_spec raises JSON::ParserError :

...
I, [2022-06-13T12:55:35.905899 #133]  INFO -- response: {"id":"120330000147955510","name":"pause_rule","evaluation_spec":{"evaluation_type":"SCHEDULE","filters":[{"field":"impressions","value":"10","operator":"GREATER_THAN"},{"field":"entity_type","value":"ADSET","operator":"EQUAL"},{"field":"time_preset","value":"THIS_MONTH","operator":"EQUAL"}]},"execution_spec":{"execution_type":"PAUSE"},"schedule_spec":{"schedule_type":"SEMI_HOURLY"}}
/home/effilab/vendor/bundle/ruby/3.1.0/gems/json-2.6.2/lib/json/common.rb:216:in `parse': 859: unexpected token at 'ADSET' (JSON::ParserError)

Steps/Sample code to reproduce the issue

Create an adrule :

hash={
      "name": "unpause_rule",
      "status": "DISABLED",
      "evaluation_spec": {
        "evaluation_type": "SCHEDULE",
        "filters": [
          {
            "field": "impressions",
            "operator": "LESS_THAN",
            "value": 1
          },
          {
            "field": "entity_type",
            "value": "ADSET",
            "operator": "EQUAL"
          },
          {
            "field": "time_preset",
            "value": "THIS_MONTH",
            "operator": "EQUAL"
          }
        ]
      },
      "execution_spec": {
        "execution_type": "UNPAUSE"
      },
      "schedule_spec": {
        "schedule_type": "SEMI_HOURLY"
      }
    }
ad_account.adrules_library.create(hash)

And then get its evaluation_spec ad_account.adrules_library.first.evaluation_spec