Microsoft Advertising API
A Microsoft API that provides programmatic access to Microsoft Advertising to manage large campaigns or to integrate your marketing with other in-house systems.
442 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi
Im trying to use the python SDK for BingAds to update an existing Audience with new hashed emails. I have managed to authenticate and read the Audience using its ID. However when i try to update the Audience using a list of hashed emails it errors with
TypeNotFound: Type not found: 'CustomerList'
Below is my function to update the Audience members:
def sync_bing_audience(hashed_emails, audience_id):
# get auth
authorization_data = bing_ads_auth()
# Initialize the CampaignManagementService
campaign_service = ServiceClient(
service='CampaignManagementService',
version=13,
authorization_data=authorization_data
)
# Create a CustomerList object
customer_list = campaign_service.factory.create("CustomerList")
customer_list.Id = audience_id
customer_list.Members = {"Emails": hashed_emails}
# Create an Audience object for updating
audience_update = campaign_service.factory.create("Audience")
audience_update.Id = audience_id
audience_update.Type = "CustomerList"
audience_update.CustomerList = customer_list
# Call UpdateAudiences with the correct object types
try:
response = campaign_service.UpdateAudiences(
Audiences={"Audience": [audience_update]}
)
print(f"Audience {audience_id} updated successfully.")
return response
except Exception as e:
print(f"An error occurred: {e}")
raise
audience_id = 821708509
response = sync_bing_audience(hashed_emails, audience_id)
I tried looking for examples on github but there are none. Could someone kindly help me correct my code or provide example code of how to do it please. Many Thanks in advance