'Facebook Business API Custom Audience delete_users function not working

I'm trying to remove users from an audience in the Facebook Ads API, using the delete_users function.

This is my code so far: '''

from collections import UserList
from facebook_business.adobjects.adaccount import AdAccount
from facebook_business.adobjects.customaudience import CustomAudience
from facebook_business.api import FacebookAdsApi
from facebook_business.api import FacebookRequest


access_token = 'XXX'

id =  'XXX' 

api = FacebookAdsApi.init(access_token=access_token)



fields = []
params = {
    'name': 'Test Audience',
    'subtype': 'CUSTOM',
    'description': 'People who purchased on my website',
    'customer_file_source': 'USER_PROVIDED_ONLY',
}
print ( AdAccount(id).create_custom_audience(
    fields=fields,
    params=params,
) )

fields = []
params = {
    'name': 'Test Audience',
    'payload': hashed_list_of_emails 
 }


CustomAudience.delete_users(
    self
    fields=fields,
    params=params,
    method='DELETE',
    endpoint='/users',
)

'''

I am receiving an error which tells me to replace self with node_id=self['id'], but I am unclear on what this is. I am also unclear on which part of the delete_users function should contain the audience_id, and where to insert the payload of the list of hashed email to remove from the audience.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source