Updating FeedItemAttribute Values

448 views
Skip to first unread message

Andi Jankovic

unread,
May 29, 2021, 7:54:37 PM5/29/21
to AdWords API and Google Ads API Forum
Hi,

I am following step by step in python the guide to update attribute values in a feed:
https://github.com/googleads/google-ads-python/blob/99b99e560b4ab6c28e0e16e8d92d1e077f6d7f15/examples/feeds/update_flights_feed_item_string_attribute_value.py

However, I keep getting the issue of:

errors {
  error_code {
    field_mask_error: FIELD_MASK_MISSING
  }
  message: "Cannot use empty field mask in update operation."
  location {
    field_path_elements {
      field_name: "operations"
      index: 0
    }
  }

Yet my code runs smoothly but there seems to be some issues when I'm copying the update_mask. Here is my code

feed_item_operation = adwords_client.get_type("FeedItemOperation")
feed_item_service = adwords_client.get_service("FeedItemService")
adwords_client.copy_from(feed_item_operation.update, feed_item)
updated_feed_item = feed_item_operation.update
adwords_client.copy_from(updated_feed_item.attribute_values[x], all_attributes[x])

# Create a field mask using the old feed_item and the updated_feed_item.
adwords_client.copy_from(
feed_item_operation.update_mask,
protobuf_helpers.field_mask(feed_item._pb, updated_feed_item._pb),
)

# Create a field mask using the old feed_item and the updated_feed_item.
feed_item_operation.update_mask.CopyFrom(
protobuf_helpers.field_mask(feed_item._pb, updated_feed_item._pb)
)

# Mutate the feeds.
response = feed_item_service.mutate_feed_items(
customer_id=client_customer_id, operations=[feed_item_operation]
)
print(
"Feed item with resource name: "
f"'{response.results[0].resource_name}' and ID: "
f"'{x}' was updated."
)

Either there is something wrong in the documentation or I'm doing something wrong. How can my field_mask be missing when everything else is completely the same as in documentation.

Thank you.
Message has been deleted

Andi Jankovic

unread,
May 29, 2021, 8:58:35 PM5/29/21
to AdWords API and Google Ads API Forum
Actually after looking deeper, if they're use copy_from with an attribute that doesnt have values changes, the whole code breaks.

On Sunday, May 30, 2021 at 1:56:11 AM UTC+2 Andi Jankovic wrote:
Also, why is there a duplication of code in the documentation? Check documentation.

Google Ads API Forum Advisor Prod

unread,
May 31, 2021, 2:25:36 AM5/31/21
to ajan...@funstage.com, adwor...@googlegroups.com

Hello Andi,

Thank you for reaching out to us.

Please note that this forum channel can only provide assistance to issues/concerns related to the AdWords API / Google Ads API.
 

With regard to the error related to Field Masks, you can check on this documentation for more details.

For your concern related to the Python client library, we suggest that you reach out to the author of the client library via this link instead.

Regards,

Google Logo
Mark Kevin Albios
Google Ads API Team
 


ref:_00D1U1174p._5004Q2Hyvva:ref
Reply all
Reply to author
Forward
0 new messages