Unexpected internal API error

2020-02-12 Thread Ignacio Guillermo Martinez
Hello, I am running into some trouble when adding criteria to an adgroup.

Traceback (most recent call last):
  File 
"/usr/local/anaconda3/lib/python3.7/site-packages/googleads/common.py", 
line 992, in MakeSoapRequest
*packed_args, _soapheaders=soap_headers)['body']['rval']
  File "/usr/local/anaconda3/lib/python3.7/site-packages/zeep/proxy.py", 
line 45, in __call__
kwargs,
  File 
"/usr/local/anaconda3/lib/python3.7/site-packages/zeep/wsdl/bindings/soap.py", 
line 130, in send
return self.process_reply(client, operation_obj, response)
  File 
"/usr/local/anaconda3/lib/python3.7/site-packages/zeep/wsdl/bindings/soap.py", 
line 195, in process_reply
return self.process_error(doc, operation)
  File 
"/usr/local/anaconda3/lib/python3.7/site-packages/zeep/wsdl/bindings/soap.py", 
line 299, in process_error
detail=fault_node.find("detail"),
zeep.exceptions.Fault: [InternalApiError.UNEXPECTED_INTERNAL_API_ERROR @ 
com.google.ads.api.services.common.error.InternalApiError.(InternalApiErro]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "add_audiences.py", line 79, in 
main(adwords_client, '')
  File "add_audiences.py", line 60, in main
response = ad_group_criterion_service.mutate(operations)
  File 
"/usr/local/anaconda3/lib/python3.7/site-packages/googleads/common.py", 
line 1004, in MakeSoapRequest
e.detail, errors=error_list, message=e.message)
googleads.errors.GoogleAdsServerFault: 
[InternalApiError.UNEXPECTED_INTERNAL_API_ERROR @ 
com.google.ads.api.services.common.error.InternalApiError.(InternalApiErro]


My code attempts to add 19 separate criteria to an adgroup given its ID, 
however it is always returning this error. You can find my code attached in 
this message also, so the error can be reproduced. 

Thanks for your time

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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/940f14bf-c6c3-4e1a-89fc-ea67f5c02ba6%40googlegroups.com.
# @author jasperan

'''
This code adds audiences at the adgroup level. A list of these audiences can be found in here:

https://developers.google.com/adwords/api/docs/appendix/codes-formats

Valid affinity categories and corresponding criterion IDs used in CriterionUserInterest.
We can also retrieve this list via the getUserInterestCriterion method of ConstantDataService by passing userInterestTaxonomyType = BRAND.
'''

from googleads import adwords

# Total of 21 audiences.
audience_ids = [80141, 92949, 92947, 93034, 93014, 92945, 93015, 93017, 80237, 93002, 92948, 80191, 80545, 92901, 80142, 80133, 93028, 80140, 93040]


def main(client, ad_group_id):
	# Initialize appropriate service.
	ad_group_criterion_service = client.GetService(
			'AdGroupCriterionService', version='v201809')

	# Create the ad group criteria.
	'''
	# Example object:
	ad_group_criteria = [
			# Targeting criterion.
			{
	'xsi_type': 'BiddableAdGroupCriterion',
	'adGroupId': ad_group_id,
	'criterion': {
			'xsi_type': 'CriterionUserInterest',
			'id': audience_ids[0]
	}
			}
	]
	'''

	ad_group_criteria = list()
	for i in audience_ids:
		aux_obj = dict()
		aux_obj['xsi_type'] = 'BiddableAdGroupCriterion'
		aux_obj['adGroupId'] = ad_group_id
		criterion_obj = dict()
		criterion_obj['xsi_type'] = 'CriterionUserInterest'
		criterion_obj['id'] = str(i)
		aux_obj['criterion'] = dict(criterion_obj)
		ad_group_criteria.append(aux_obj)

	print('Full object: {}'.format(ad_group_criteria))
	
	# Create operations.
	operations = []
	for criterion in ad_group_criteria:
		operations.append({
'operator': 'ADD',
'operand': criterion
		})

	response = ad_group_criterion_service.mutate(operations)

	if response and response['value']:
		criteria = response['value']
		for ad_group_criterion in criteria:
			criterion = ad_group_criterion['criterion']
			print('Ad group criterion with ad group ID %s, criterion ID %s and '
		'type "%s" was added.' %
		(ad_group_criterion['adGroupId'], criterion['id'],
		 criterion['type']))
	else:
		print('No criteria were returned.')
	


if __name__ == '__main__':
	# Initialize client object.
	adwords_client = adwords.AdWordsClient.L

Adding audiences through the API

2020-01-15 Thread Ignacio Guillermo Martinez
How can I add a set of audiences to my adgroup based on a set of IDs?

For example:

Audience 
Financial Services>Credit & Lending>Credit Cards 
News & Politics 
Lifestyles & Hobbies 
Media & Entertainment 
with their corresponding IDs:

ID 
80141 
92949 
92947 
93034 

Is there any way to do this easily, like adding negative targeting criteria 
to a campaign?

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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/8dd5d981-614e-4183-ab1e-5e5c68617925%40googlegroups.com.


How to download a custom report through the API?

2019-10-16 Thread Ignacio Guillermo Martinez
Hello, I have been searching information on how to download custom reports 
(or predefined ones) through the API. I was wondering if this is possible. 
The only information I have found about it is the following, but I am not 
sure if it corresponds to what I'm trying to do:

https://developers.google.com/adwords/api/docs/guides/reporting#complete_example

I need this because currently I am working on a project and we need to 
download reports everyday manually and perform the ETL afterwards, it would 
be great if I could automate the whole process.

Thanks for your help

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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/923ea424-55bc-4ea2-9637-b077a9140b41%40googlegroups.com.


AddGmailAdd.java APIException

2019-09-17 Thread Ignacio Guillermo Martinez


Hello, I need to create a GmailAd. However, when modifying the code example 
in:


https://github.com/googleads/googleads-java-lib/blob/967957cc4f6076514e3a7926fe653e4f1f7cc9c9/examples/adwords_axis/src/main/java/adwords/axis/v201809/advancedoperations/AddGmailAd.java


Adding my own AdGroupId, I get the following exception:


*Request failed due to ApiException. Underlying ApiErrors: Error 0: 
NullError{apiErrorType=NullError, errorString=NullError.NULL_CONTENT, 
fieldPath=media[0].data, fieldPathElements=[FieldPathElement{field=media, 
index=0}, FieldPathElement{field=data}], reason=NULL_CONTENT, trigger=}*


I have investigated about the NullError exception: 
https://developers.google.com/adwords/api/docs/reference/v201809/ReportDefinitionService.NullError

However the code example doesn't seem to have any issues (nothing seems to 
be null when printing it).


Appreciate any help at this point.

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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/843a099d-0443-437f-821a-f3ab8bfc7f62%40googlegroups.com.