Hello,
When I am running below code in mu local it is running fine and returning 
proper result but when I am running same code in Airflow it is giving me 
error for version.

*Airflow Error :-*
b"googleads.errors.GoogleAdsValueError: Unrecognized version for the 
AdWords API. Given: v201809 Supported: ['v201609', 'v201702', 'v201705', 
'v201708']\n"

*Code:-*

#!/usr/bin/env python
#
# Copyright 2016 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""This example gets all campaigns.
To add a campaign, run add_campaign.py.
The LoadFromStorage method is pulling credentials and properties from a
"googleads.yaml" file. By default, it looks for this file in your home
directory. For more information, see the "Caching authentication 
information"
section of our README.
"""

from googleads import adwords

PAGE_SIZE = 100
def main(metro_criteria_id):
# Initialize appropriate service.
location_criterion_service = adwords_client.GetService(
'LocationCriterionService', version='v201809')
location_names_metro = metro_criteria_id
# Create the selector.
selector = {
'fields': ['Id', 'LocationName', 'DisplayType', 'CanonicalName',
'ParentLocations', 'Reach', 'TargetingStatus'],
'predicates': [{
'field': 'Id',
'operator': 'IN',
'values': location_names_metro
}, {
'field': 'Locale',
'operator': 'EQUALS',
'values': ['en']
}]
}

# Make the get request.
location_criteria = location_criterion_service.get(selector)
print(f'location criteria....{location_criteria}')

if __name__ == '__main__':
adwords_credentials = gen_api_credentials()
global adwords_client
adwords_client = adwords.AdWordsClient.LoadFromString(adwords_credentials)
print('start')
main(20652)

*Result:*
start
location criteria....[{
    'location': {
        'id': 20652,
        'type': None,
        'Criterion.Type': 'Location',
        'locationName': 'Nara',
        'displayType': 'Prefecture',
        'targetingStatus': 'ACTIVE',
        'parentLocations': [
            {
                'id': 9073778,
                'type': None,
                'Criterion.Type': 'Location',
                'locationName': 'JP_KINKI',
                'displayType': 'DMA Region',
                'targetingStatus': 'ACTIVE',
                'parentLocations': []
            },
            {
                'id': 2392,
                'type': None,
                'Criterion.Type': 'Location',
                'locationName': 'Japan',
                'displayType': 'Country',
                'targetingStatus': 'ACTIVE',
                'parentLocations': []
            }
        ]
    },
    'canonicalName': 'Nara,Japan',
    'reach': 1230000,
    'locale': None,
    'searchTerm': None,
    'countryCode': None
}]

Process finished with exit code 0

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/82cf1b68-1071-4de8-a430-275fd3efaedan%40googlegroups.com.
  • Lo... Jayant Meshram
    • ... 'Google Ads API Forum Advisor' via AdWords API and Google Ads API Forum

Reply via email to