we are making request calls as follows:

twitter.do_request(f'https://ads-api.twitter.com/11/stats/jobs/accounts/{user_id_encode}',{'entity':entity,'entity_ids':','.join(tweets),'start_time':start_date,'end_time':end_date,'granularity':granularity,'placement':placement,'metric_groups':metric_groups},'post')

using the next fuction:

def do_request(self, end_point, params,request_type):
        if request_type == 'post':
            response = self.oauth.post(
                end_point, params=params
            )
        elif request_type == 'get':
            response = self.oauth.get(
                end_point, params=params
            )
        else:
            1/0
        if response.status_code != 200:
            raise Exception(
                "Request returned an error: {} {}".format(response.status_code, response.text)
            )

        json_response = response.json()
        
        return json_response

When we try to bring the information (public metrics) for the tweets_ids of an account it does not return any information, but with other accounts it does.

We want to know why this account we can not bring information if we have the same permissions as the other accounts.

Could you give us a step by step of the permissions required to validate it?

Hello,

Thanks for reaching out. Could you share the AccountID as well as the entity_ids which you are querying for? This information isn’t considered sensitive and cannot be used by unauthorized users in any way.

Hi,

Thanks for you response.

The account id is: 124265021 and advertiser id: 18ce55f4quc

The entitys ids is : [1562120970852237312,1560290990937833472,1559943707813724160,1555720072878084104]

Hello,

Thanks for reaching out. As per checking, these entity IDs: [1562120970852237312,1560290990937833472,1559943707813724160,1555720072878084104] belongs to the Ads account ID: 18ce55fo83o (Twitter Handle: @bonyurt)

When performing the Asynchronous call, you need to do a POST call to the Ads Account 18ce55fo83o to retrieve the necessary data.

E.g.

twurl -H ads-api.twitter.com "/11/stats/jobs/accounts/18ce55fo83o?start_time=2022-08-24&end_time=2022-08-28&entity=ORGANIC_TWEET&entity_ids=1562120970852237312,1560290990937833472,1559943707813724160,1555720072878084104&metric_groups=ENGAGEMENT&granularity=TOTAL&placement=ALL_ON_TWITTER" -X POST | jq .

I see that the Ads account 18ce55f4quc is an admin for the ads account 18ce55fo83o. As such, when performing the API call, you can use the token for 18ce55f4quc to retrieve the data for ads account 18ce55fo83o.

However, in the POST API call, you need to specify /accounts/18ce55fo83o instead of /accounts/18ce55f4quc as the organic tweet belongs to the Ads account 18ce55fo83o

Hope this clarifies.

Hi,

We manage an account (@TaagColombia1) in this account we have administrator permissions for the following accounts (@bonyurt, @Alpina, @McDonaldsCol and @`elqlubalpina) among others.

In other words, we generate the tokens from our account ( TaagColombia1).

With all the accounts we can retrieve information on the entity IDs corresponding to each account, but when we go to retrieve the information on the entity IDs of (@bonyurt) it does not bring us information.

It only happens to us with this account, but we have administrator permissions.

Hello,

So can i verify that when you perform this API call:

twitter.do_request(f'https://ads-api.twitter.com/11/stats/jobs/accounts/{user_id_encode}',{'entity':entity,'entity_ids':','.join(tweets),'start_time':start_date,'end_time':end_date,'granularity':granularity,'placement':placement,'metric_groups':metric_groups},'post')

The account param is 18ce55fo83o? And you are using the token of 18ce55f4quc to perform the API call? Reason being, on my end, I tried to perform the API as accountID 18ce55f4quc and I managed to retrieve data for the accountID18ce55fo83o.

On your end, can you verify that the token for accountID 18ce55f4quc has been passed correctly?

Hello,

We use the tokens of this account @TaagColombia1,

And we want to bring the metrics of the 18ce55fo83o account, that is, impressions, clicks, etc. for organic tweets.

We use this request:

do_request(f'https://ads-api.twitter.com/11/stats/jobs/accounts/{user_id_encode}',{'entity':entity,'entity_ids':','.join(tweets) ,'start_time':start_date,'end_time':end_date,'granularity':granularity,'placement':placement,'metric_groups':metric_groups},'post')

With this we have a job_id and we do the following query:

`get_request(f'https://ads-api.twitter.com/11/stats/jobs/accounts/{user_id_encode}',{'job_ids':id_job},str(start_date),str(end_date))`

where:

def get_request(self, end_point, params,start_date,end_date):
        result = []
        boolean = True
        while boolean:
            response = self.oauth.get(
                end_point, params=params
            )
    
            if response.status_code != 200:
                raiseException(
                    "Request returned an error: {} {}".format(response.status_code, response.text)
                )
    
           
            boolean_2 = True
            for result in response.json().get('data'):
                
                if result.get('status') != 'SUCCESS':
                        print('Waiting 30 seconds')
                        time.sleep(30)
                        boolean_2 = False
                        break
            if boolean_2:
                boolean = False
        json_response = response.json()
        urls = [result.get('url') for result in response.json().get('data')]
        to_return = [ pd.DataFrame(columns = list(schema.schemas.get('tweet_metrics').keys()))]
        for url in urls:
            name_arch = url.split('/')[-1]
            wget.download(url,archname)
            x = gzip.open(arch_name,'rb').read()
            x = json.loads(x)
            end_date = (datetime.strptime(end_date,'%Y-%m-%d')-timedelta(days=1)).strftime('%Y-%m-%d')
            for i in range(len(x['data'])):
                df = pd.DataFrame(x['data'][i]['id_data'][0]['metrics'],index=pd.date_range(start=start_date, end=end_date, freq='D'), dtype='str')
                df['day'] = df.index
                df['tweet_id'] = x['data'][i]['id']
                ## Look at the same case of report_to_df when it is a list
                to_return.append(df)
        return pd.concat(to_return, ignore_index=True)

By making this last call we hope that it will bring us the requested metrics:

metric_groups = ‘ENGAGEMENT,VIDEO’

But with the 18ce55fo83o account it does not bring us the information, although with the 18ce55icp5a, 18ce54tida1 and 18ce55f4quc accounts it does bring us information using the same tokens for all accounts.

Hello,

On my end I am still unable to reproduce the issue. I managed to use the account 18ce55fxrj7 (@TaagColombia1) to retrieve data of the Ads account 18ce55fo83o successfully.

Maybe you can try regenerating the token for 18ce55fxrj7 (@TaagColombia1) and try to perform the API call again?