Ads data hub API analysis query

187 views Asked by At

How we can execute all the analysis queries for Ads data hub using API in python as I am able to run single query but data is not saving in Daaset

Added a service account created for this run into Ads data hub Interface user as Super User

I am trying to run all the queries for a customer using API

I tried running a single query using below method

queries=service.customers().analysisQueries().start(

        name='customer_name',
        body={
            'spec': {
                'adsDataCustomerId': '',
                'timeZone': 'UTC',
                'startDate': {'year': 2022, 'month': 12, 'day': 1},
                'endDate': {'year': 2022, 'month': 12, 'day': 12},
            },
            'destTable' : 'projectName.datasetName.Table'
        }
    ).execute()
After running these queries I am getting response as querymetadata as below 

{"name": "": {"@type": "type.googleapis.com/google.ads.adsdatahub.v1.QueryMetadata", "queryResourceName": "", "queryTitle": "title of the query", "customerId": "customerId", "adsDataCustomerId": "adsdatacustomerId", "matchDataCustomerId": "", "parameterValues": {"start_date": {"value": ""}, "end_date": {"value": ""}, "time_zone": {"value": "UTC"}}, "startTime": "", "endTime": "", "destTable": ""}}

But data is not saving in Big query data set
1

There are 1 answers

0
Adventurous Leo On
"name" is not the customer name, it should be the resource name, like "customers/(Customer ID)/analysisQueries/(queryID)"
Also, adsDataCustomerID should not be blank.
adsDataCustomerID should be the ID of your ADH account, and customerID is the ID of your ADH link to your ads platform (either Google Ads or DV360).

you can run service.customers().analysisQueries().list(parent=customer_name).execute() to get the queryID of all your stored queries.