How can I retrieve campaigns from campaign_criterion by label name?

61 views
Skip to first unread message

Alejandro Bar Acedo

unread,
Feb 13, 2023, 10:00:54 AM2/13/23
to Google Ads API and AdWords API Forum
Using the Google Ads Query Builder I created this query:

SELECT
  campaign.id,
  campaign.name,
  campaign_criterion.location.geo_target_constant,
  campaign_criterion.proximity.geo_point.latitude_in_micro_degrees,
  campaign_criterion.proximity.geo_point.longitude_in_micro_degrees,
  campaign_criterion.proximity.radius,
  campaign_criterion.proximity.radius_units,
  campaign_criterion.negative
FROM campaign_criterion
WHERE
  campaign.labels CONTAINS ALL ('my_label')
  AND campaign.status = 'ENABLED' 

but when I execute it I get this error: "Resource name 'my_label' is malformed: expected 'customers\/{customer_id}\/labels\/{label_id}'."

Google Ads API Forum Advisor

unread,
Feb 13, 2023, 1:21:24 PM2/13/23
to ab...@habitissimo.com, adwor...@googlegroups.com

Hi Alejandro,

Thank you for reaching out to Google Ads API Forum.

According to the Campaign object definition, Campaign.labels[] is the resource names of labels (objects) attached to this campaign. Hence, the reason for the error you encountered, “Resource name 'my_label' is malformed: expected 'customers\/{customer_id}\/labels\/{label_id}' is because my_label is not a valid resource name.

Can you try replacing my_label with a valid label resource name? 
For example: customers/{customerId}/labels/{label_id}

You may use the label.resource_name from the label report to retrieve the resource names of labels. Let me know how it goes on your end if this resolves your issue. In the event that the error persists after trying the suggested solution, then you may provide to us the complete request and response logs with the request-id generated from your end so we can investigate further. 

You can provide it via the Reply privately to author option. If this option is not available, then send it instead on this email address googleadsa...@google.com.

Regards,

Google Logo
Abigail
Google Ads API Team
 


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