KeyError: 'location' during BatchJobProcessing

125 views
Skip to first unread message

martin...@auto1.com

unread,
Feb 12, 2016, 9:08:04 AM2/12/16
to AdWords API Forum
Hello,
I'm facing a problem concerning a BatchJob process. I recreated my code with the code sample you provided "add_complete_campaigns_using_batch_job.py". Even when just executing the sample you provided I'm facing the following error message (see below). Am I doing something wrong or are you facing the same problem?

I use Python 2.7, the latest version of the API (v201601).

Thanks for your help
Martin

Traceback (most recent call last):
  File "/Users/UserName/PycharmProjects/AdwordsAPI/Bid_Implementer/add_complete_campaigns_using_batch_job.py", line 430, in <module>
    NUMBER_OF_KEYWORDS_TO_ADD)
  File "/Users/MartinWinkel/PycharmProjects/AdwordsAPI/Bid_Implementer/add_complete_campaigns_using_batch_job.py", line 70, in main
    adgroup_criterion_operations, adgroup_ad_operations)
  File "/Users/UserName/.virtualenvs/adwordsAPI/lib/python2.7/site-packages/googleads/adwords.py", line 815, in UploadOperations
    version=self._version)
  File "/Users/UserName/.virtualenvs/adwordsAPI/lib/python2.7/site-packages/googleads/adwords.py", line 884, in __init__
    self._upload_url = self._InitializeURL(upload_url, current_content_length)
  File "/Users/UserName/.virtualenvs/adwordsAPI/lib/python2.7/site-packages/googleads/adwords.py", line 917, in _InitializeURL
    return resp.headers['location']
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/rfc822.py", line 393, in __getitem__
    return self.dict[name.lower()]
KeyError: 'location'

Process finished with exit code 1

Yin Niu

unread,
Feb 12, 2016, 11:56:28 AM2/12/16
to AdWords API Forum
Hello, 

The error is saying there's no "location" key in the response header, but it should always be there, assuming that the job was successfully created. I tried both v201509 and v201601 with no issue. Could you please try again and make sure you install the correct libraries? The last line in my add_complete_campaigns_using_batch_job.py is 428 and line 70 is a comment line. In the error message, it's referencing line 430 and line 70.  

Thanks,
Yin, AdWords API Team. 

Alex G.

unread,
Feb 29, 2016, 11:35:09 AM2/29/16
to AdWords API Forum
Hi,
Just ran into the same issue running one of the examples.
@Martin, where you able to find the cause?
Thanks in advance
Reply all
Reply to author
Forward
0 new messages