Get custom data in response when calling mutate()

100 views
Skip to first unread message

David Denton

unread,
Jun 14, 2016, 8:43:59 PM6/14/16
to AdWords API Forum
I'm synchronizing a number of Ad Groups from a web app (where they are created) to the customer's AdWords Account via the API.

operations = [ad_group_1, ad_group_2, ad_group_3 ....] 

Each AdGroup object has an attribute 'google_id' which is the ID key Google uses to identify the object. 

After calling client.mutute(operations) I would like to be able to update the 'google_id' attribute for each updated object, and I would like to do this by passing the primary key of the AdGroup object to some sort of field in the operation, and for that value to be returned so I can do something like:

response = client.mutute(operations)

for item in response['items']
    adgroup_id = item['my_custom_id_field]
    adgroup = get_adgroup_by_id(adgroup_id )

Is this possible?

Umesh Dengale

unread,
Jun 15, 2016, 10:03:14 AM6/15/16
to AdWords API Forum
Hello,

The AdGroup is identified by field id. When you create the AdGroup using mutate operation (with Add operator), this id is generated by the AdGroupService. The id field could not updated with some other value using mutate (SET operator). Please check out AdGroup document for more details.

Thanks,
Umesh, AdWords API Team.

David Denton

unread,
Jun 16, 2016, 5:57:35 AM6/16/16
to AdWords API Forum
Hi Umesh,

Thanks for the response but doesn't really answer my question..

There are 2 AdGroups: AdGroup object in my site (say MyAdGroup) and The actual AdGroup in Google (say GoogleAdGroup).

When I push MyAdGroup to Google I want to be able to update MyAdGroup.google_id with GoogleAdGroup.id, but to do this I'm hoping I can pass a custom field with MyAdGroup.id in the mutate() operations, so that when I get the response I can do something like MyAdGroup.get_by_id(GoogleAdGroup.my_custom_field).

Is this possible?

Shwetha Vastrad (AdWords API Team)

unread,
Jun 16, 2016, 6:11:07 PM6/16/16
to AdWords API Forum
Hi David,

To clarify, you want to be able to use your custom ID for AdGroupId(Google AdWords) so that you can use this field to query for the AdGroup in your Web app? I'm afraid the ID of the AdGroup cannot be set. It is a read-only field. You could consider using AdGroupLabels which can be set using a AdGroupService.mutateLabel operation.

Regards,
Shwetha, AdWords API Team.

David Denton

unread,
Jun 17, 2016, 5:33:34 PM6/17/16
to AdWords API Forum
Hi

Thanks for the response.

Is there any guarantees the API can make about the order of the entries in the response?

For example if the request was sent something like:

operations = [adgroup_1, adgroup_2, adgroup_3]
response = client.mutate(operations)

print response['entries'] # >> [adgroup_1, adgroup_2, adgroup_3]

where the order is guaranteed?

Thanks

David

Shwetha Vastrad (AdWords API Team)

unread,
Jun 20, 2016, 11:29:12 AM6/20/16
to AdWords API Forum
Hi David,

All of the operations will be returned in the response in the same order as you passed them to the server. 
Reply all
Reply to author
Forward
0 new messages