facebook/facebook-python-business-sdk

Batch Execute Error

jlpetracca opened this issue · 1 comments

  • Lastest version

I am trying to read some Adcreative in a batch but i have this error

AttributeError: 'FacebookAdsApi' object has no attribute 'GRAPH'

this is the code

`from facebook_business import FacebookSession
from facebook_business import FacebookAdsApi
from facebook_business.adobjects.adaccount import AdAccount
from facebook_business.adobjects.ad import Ad
from facebook_business.adobjects.adset import AdSet

session = FacebookAdsApi.init(my_app_id, my_app_secret, my_access_token,api_version='v15.0')
api = FacebookAdsApi(session)

FacebookAdsApi.set_default_api(api)
my_api_batch = api.new_batch()

AdCreative('ADIDADIDADID').api_get(batch = my_api_batch , fields=[
AdCreative.Field.account_id,
])

AdCreative('ADIDADIDADID').api_get(batch = my_api_batch , fields=[
AdCreative.Field.account_id,
])
my_api_batch.execute()`

this is the error

`---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Input In [8], in
16 AdCreative('ADIDADIDADID').api_get(batch = my_api_batch , fields=[
17 AdCreative.Field.account_id,
18 AdCreative.Field.actor_id,
(...)
27
28 ])
30 AdCreative('ADIDADIDADID').api_get(batch = my_api_batch , fields=[
31 AdCreative.Field.account_id,
32 AdCreative.Field.actor_id,
(...)
41
42 ])
---> 45 my_api_batch.execute()

File /opt/homebrew/lib/python3.9/site-packages/facebook_business/api.py:510, in FacebookAdsApiBatch.execute(self)
507 if call_files:
508 files.update(call_files)
--> 510 fb_response = self._api.call(
511 method,
512 path,
513 params=params,
514 files=files,
515 )
517 responses = fb_response.json()
518 retry_indices = []

File /opt/homebrew/lib/python3.9/site-packages/facebook_business/api.py:301, in FacebookAdsApi.call(self, method, path, params, headers, files, url_override, api_version)
296 self._num_requests_attempted += 1
298 if not isinstance(path, six.string_types):
299 # Path is not a full path
300 path = "/".join((
--> 301 url_override or self._session.GRAPH,
302 api_version,
303 '/'.join(map(str, path)),
304 ))
306 # Include api headers in http request
307 headers = headers.copy()

AttributeError: 'FacebookAdsApi' object has no attribute 'GRAPH'`

Same error, do we have a work around?