Re: How to change keyword status via the Python libraries

2018-09-03 Thread tom . wagstaff
Hi Milind,

That's fixed it - works as expected now - thank you!

Cheers,
Tom

On Friday, August 31, 2018 at 9:21:46 PM UTC+1, Milind Sankeshware (AdWords 
API Team) wrote:
>
> Hi Tom,
>
> To change the keyword status, you will need to set the UserStatus 
> 
>  of 
> your BiddableAdGroupCriterion 
> 
>  of 
> type Keyword 
> 
>  using 
> the AdGroupCriterionService.mutate() 
> 
>  method. 
> We don't have the sample example to update the status of keyword. Please 
> refer my sample code below:
>
>   operations = [{
>   'operator': 'SET',
>   'operand': {
>   'xsi_type': 'BiddableAdGroupCriterion',
>   'adGroupId': ad_group_id,
>   'criterion': {
>   'id': criterion_id,
>   },
> 'userStatus': 'PAUSED'
>   
>   }
>   }]
>
> Looks like you are missing *xsi_type': 'BiddableAdGroupCriterion* in your 
> code. Could you please give a try and let me know if you are still facing 
> an issue. 
>
> Thanks,
> Milind, AdWords API Team
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/91c4f615-1465-4553-ad75-0a3d8ccc8b8c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to change keyword status via the Python libraries

2018-08-31 Thread 'Milind Sankeshware (AdWords API Team)' via AdWords API and Google Ads API Forum
Hi Tom,

To change the keyword status, you will need to set the UserStatus 

 of 
your BiddableAdGroupCriterion 

 of 
type Keyword 

 using 
the AdGroupCriterionService.mutate() 

 method. 
We don't have the sample example to update the status of keyword. Please 
refer my sample code below:

  operations = [{
  'operator': 'SET',
  'operand': {
  'xsi_type': 'BiddableAdGroupCriterion',
  'adGroupId': ad_group_id,
  'criterion': {
  'id': criterion_id,
  },
'userStatus': 'PAUSED'
  
  }
  }]

Looks like you are missing *xsi_type': 'BiddableAdGroupCriterion* in your 
code. Could you please give a try and let me know if you are still facing 
an issue. 

Thanks,
Milind, AdWords API Team

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/5af9e8f4-e9e7-432f-8a70-47e926ac3339%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to change keyword status via the Python libraries

2018-08-31 Thread tom . wagstaff
Hi community,

I am struggling to work out how to change keyword status via the Google Ads 
API using the Python library. I have no problem pausing and enabling 
AdGroups, or adding new keywords, but there is no exact model for this in 
the sample code, and my alterations are not working as expected. Here is 
the function I'm trying, based closely on the sample code:

def enableKeyword(client, ad_group_id, criterion_id):
  # Initialize appropriate service.
  ad_group_criterion_service = client.GetService(
  'AdGroupCriterionService', version='v201806')

  # Construct operations and update bids.
  operations = [{
  'operator': 'SET',
  'operand': {
  'adGroupId': ad_group_id,
  'criterion': {
  'id': criterion_id
  },
  'userStatus': 'ENABLED'
  }
  }]
  ad_group_criteria = ad_group_criterion_service.mutate(operations)

  # Display results.
  if 'value' in ad_group_criteria:
for criterion in ad_group_criteria['value']:
  if criterion['criterion']['Criterion.Type'] == 'Keyword':
print(('Ad group criterion with ad group id "%s" and criterion id '
   '"%s" currently has bids:'
   % (criterion['adGroupId'], criterion['criterion']['id'])))
for bid in criterion['biddingStrategyConfiguration']['bids']:
  print('\tType: "%s", value: %s' % (bid['Bids.Type'],
 bid['bid']['microAmount']))
  else:
print('No ad group criteria were updated.')

As far as I can see this follows the same structure as the (apparently) 
functioning C# code posted here: 
https://stackoverflow.com/questions/28046602/how-to-update-keyword-status-maxcpc-and-keyword-text-using-google-adwords-api?rq=1
but Python just gives me a KeyError complaining about userStatus - so it's 
obviously not expected there.

What am I missing?

Cheers,
Tom

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/4f3e183d-88a3-4304-bf8a-9f56373fc83c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.