BingAds / BingAds-Python-SDK

Other
118 stars 164 forks source link

AttributeError: 'Text' object has no attribute 'Campaign' #267

Open nbro10 opened 11 months ago

nbro10 commented 11 months ago

We've been getting this error for quite some time.

Specifically, we make the following request

...
result = campaign_service.GetCampaignsByAccountId(
            AccountId=account_id,
            CampaignType=CAMPAIGN_TYPES,
            ReturnAdditionalFields=['CpvCpmBiddingScheme'],
        )
...

And then do the following

...
records = ((str(cc.Name), int(cc.Id)) for cc in result.Campaign)
...

which is the line that triggers the error in the title.

Now, according to the documentation, result should be an array of Campaign objects or an empty array if there are no campaigns, so what we're doing should always work, unless the documentation is outdated. In that case, can you please tell us what are all the types that may be returned by GetCampaignsByAccountId, when they are returned and any recommendation on how to handle all the cases.

By looking at the logs, result seems to be an empty string, although I think this is just how the Text object is printed (because the error message says it's Text object not str. If look at the account for which we are trying to get the campaigns, it seems it has no campaign (at least, I can't see any in the UI).

So, can you confirm that this happens when the account has no campaigns, and that this is a bug in this package? In any case, I think this package should return an empty list instead of an empty string or Text in that case.

Thanks.