Im stock here in CreateHttpHeader error

36 views
Skip to first unread message

Mark Anthony Gutierrez

unread,
Mar 1, 2018, 4:20:19 PM3/1/18
to AdWords API Forum
Traceback (most recent call last):
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\exception.py", line 35, in inner
    response = get_response(request)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\base.py", line 128, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\base.py", line 126, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "C:\Users\xxx\Desktop\project\ksvt\views.py", line 68, in generate
    main(adwords_client)
  File "C:\Users\xxx\Desktop\project\ksvt\views.py", line 118, in main
    page = targeting_idea_service.get(selector)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python36-32\lib\site-packages\googleads\common.py", line 774, in MakeSoapRequest
    self._header_handler.SetHeaders(self.suds_client)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python36-32\lib\site-packages\googleads\adwords.py", line 514, in SetHeaders
    http_headers = self._adwords_client.oauth2_client.CreateHttpHeader()
AttributeError: 'str' object has no attribute 'CreateHttpHeader'


All credentials are passed correctly:
adwords_client = adwords.AdWordsClient(
'dev-token',
'client-id',
'user-agent',
client_customer_id= 'xxx-xxx-xxx')

Vincent Racaza (AdWords API Team)

unread,
Mar 2, 2018, 12:29:56 AM3/2/18
to AdWords API Forum
Hi,

Based on your code snippet, it seems that you are not utilizing the property file in getting the details of your credentials. I recommend that you use the property file so you don't need to set these values in every example/code you are using.

Also, in your code snippet, you did not set the client secret and refresh token which are required fields for every API request. Please check this guide to help you get started.

Thanks,
Vincent
AdWords API Team
Message has been deleted

Mark Anthony Gutierrez

unread,
Mar 2, 2018, 3:50:17 AM3/2/18
to AdWords API Forum
Hello Vincent,

Im trying not to use the google.yaml and in the adwords.AdwordsClient parameters there's no indicating that I need the secret token and the refresh token.

Also I tried to use googleads.yaml and I got this error:


File "C:\Users\xxx\AppData\Local\Programs\Python\Python36-32\lib\site-packages\googleads\adwords.py", line 286, in LoadFromStorage
    cls._OPTIONAL_INIT_VALUES))
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python36-32\lib\site-packages\googleads\common.py", line 263, in LoadFromStorage
    'Given yaml file, %s, could not be opened.' % path)
googleads.errors.GoogleAdsValueError: Given yaml file, C:\Users\MaC\Desktop\project\ksvt, could not be opened.

Vincent Racaza (AdWords API Team)

unread,
Mar 2, 2018, 4:04:14 AM3/2/18
to AdWords API Forum
Hi Mark,

You need to set the client secret and refresh token as they are required fields in the authentication.

In regards to your error, it seems that it could not locate/open the googleads.yaml file based on this error message "C:\Users\MaC\Desktop\project\ksvt, could not be opened". Please double check on your end if the correct path was being set in the LoadFromStorage('path_of_your_yaml_file') method. Or, you can also put the googleads.yaml file in your home directory as you can see in this guide.

Mark Anthony Gutierrez

unread,
Mar 2, 2018, 4:23:36 AM3/2/18
to AdWords API Forum
Hello Vincent,

I have successfully get a request using LoadFromStorage(). Thanks a lot for the help! Kudos!
Reply all
Reply to author
Forward
0 new messages