pythonpython-3.xgoogle-apigoogle-api-clientgoogle-client

Query ADH using a filter


I am trying to query the Google ADH API (https://developers.google.com/ads-data-hub/reference/rest/v1/customers.adsDataLinks/list)

For reference I get a response sample as:

  {'name': 'customers/68689789/adsDataLinks/XXXXXXXXXX',
  'linkedEntity': {'entityId': '897777777', 'type': 'GOOGLE_ADS_CAMPAIGN'},
  'parentEntity': {},
  'platform': 'GOOGLE_ADS',
  'customerLink': {'name': 'xyz/780/78',
  'customerId': '97896868',
   'displayName': 'VENDOR_ID'},
  'status': 'APPROVED',
  'createTime': '2020-04-04T16:51:47.738710Z',
  'updateTime': '2020-04-04T16:51:47.738710Z'
}

I have everything set up so that I can query ADH using a client. I have written a function

        datesss='2020-04-04T16:51:47.738710Z'
        kwargs = {
            'parent': self.parent,
            'filter':f"updateTime={datesss}",
            'pageSize': 1,
            'pageToken': pageToken
        }
        request = self.service.customers().adsDataLinks().list(**kwargs)
        response = self.execute_adh_request(request)

        return response.get('links', []), response.get('nextPageToken', '')

I get this error: HttpError: <HttpError 400 when requesting https://adsdatahub.googleapis.com/v1/customers/802/adsDataLinks?filter=updateTime%3D2020-04-04T16%3A51%3A47.738710Z&pageSize=1&pageToken=&key=AIzaSyBsDsBR-PhJu2kUiH9O_tRgLfdLP9L_YUo&alt=json returned "Invalid filter expression: updateTime=2020-04-04T16:51:47.738710Z (Error 0420)">

I then enclosed the filter expression as such as

'filter':f"updateTime='{datesss}'"

NOTE: This is just a sample, I want to extract all links that have a creation date in 2021 Please can someone guide me how I can use the filter function to do this.


Solution

  • Currently, ADH doesn't support filtering on the createTime, updateTime