Trying to remove via REST API accounts I’m sharing a tailored audience with. I’m following the documentation here (Overview | Docs | Twitter Developer Platform), and my permissions do other things fine like create and delete audiences.

Request:
import requests
from requests_oauthlib import OAuth1

audienceId = ‘2wbde’
permissionId = ‘5e3’

ConsumerKey =‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxx’
ConsumerSecret = ‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’
AccessToken= ‘xxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxx’
AccessTokenSecret = ‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’
client = OAuth1(ConsumerKey, ConsumerSecret, AccessToken, AccessTokenSecret)

url = ‘https://ads-api.twitter.com/5/accounts/18ce54ekdg9/tailored_audiences/{0}/permissions/{1}
response = requests.delete(url.format(audienceId, permissionId), auth = client)
data = response.content
data = data.decode(‘utf-8’)
print(data)

Response:
{“errors”:[{“code”:“NOT_FOUND”,“message”:“Granted account id 17ef5323gyl was not found”}],“request”:{“params”:{“account_id”:“29ce32ekef8”,“tailored_audience_permission_id”:“5e3”,“tailored_audience_id”:“2wbde”}}}

@eaglennsworld

Did you already delete that TA list? (id: 2wbde) The error message looks legit to me as that account id indeed doesn’t exist anymore.

1 Like

Hi @jrsyo, thanks for the reply. I changed up all of the account IDs in the request above, but here is the call with the actual account IDs and permission IDs I’m using.

import requests
from requests_oauthlib import OAuth1

ConsumerKey =‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxx’
ConsumerSecret = ‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’
AccessToken= ‘xxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxx’
AccessTokenSecret = ‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’
client = OAuth1(ConsumerKey, ConsumerSecret, AccessToken, AccessTokenSecret)

url = ‘https://ads-api.twitter.com/5/accounts/18ce54ekdg9/tailored_audiences/2mbig/permissions/2s5
response = requests.delete(url, auth = client)
data = response.content
data = data.decode(‘utf-8’)
print(data)

Also, the correct response is below. Sorry, didn’t realize you were able to look into the actual validity of the account IDs.

{“errors”:[{“code”:“NOT_FOUND”,“message”:“Granted account id 18ce53x5gsl was not found”}],“request”:{“params”:{“account_id”:“18ce54ekdg9”,“tailored_audience_permission_id”:“2s5”,“tailored_audience_id”:“2mbig”}}}

@eaglennsworld

When you performed the request, which handle user did you use to authenticate? Seems like there’s only one handle user account that has permission for both Ads account.

1 Like

@jrsyo I used the hande ‘eaglennsworld’. While logged into this account I am able to remove the accounts from the audience via the UI.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.