Hi Matthias,

I went to check this out, as I think I need to do this for my issue.

I was able to get the parent criterion id using the AdGroupCriterionService 
get selector

Looks like something like this would work - but I've not put it in practice 
other than a quick test.

def main(client, adgroup_id):
  """Runs the example."""
  adgroup_criterion_service = client.GetService(
      'AdGroupCriterionService', version='v201806')

  selector = {
    'fields':['ParentCriterionId'],
      'predicates':[
          {
              'field':'AdGroupId',
              'operator': 'EQUALS',
              'values': adgroup_id
          }
      ]
  }
  page = adgroup_criterion_service.get(selector)

  print page['entries'][0]['criterion']['id']


It appears that the root partition is the first entry in the list so you can 
grab it using [0].  You should be able to confirm it - as the 
page['entries'][0]['criterion']['idparentcriterionId] should be None.


On Friday, October 26, 2018 at 10:22:54 AM UTC-5, Matthias Baader wrote:
>
> Hi, 
>
> if I understand that correctly, you can find the root product group id by 
> searching for the product group that does not have a parent product id. 
> Right?
>
> But how exactly does the AWQL query in Python have to look like?
>
> Is the following code correct?
>
>   report_query = (adwords.ReportQueryBuilder()
>                   .Select('CampaignId', 'AdGroupId', 'Id', 
> 'ParentCriterionId')
>                   .From('PRODUCT_PARTITION_REPORT')
>                   .Where('ParentCriterionId').In(0)#<is this line correct?
>                   .Build())
>
> It seems to work, but I'm struggling with the .In(0) - part, because the 
> service reference states "Undefined for the root partition": 
>
>
> https://developers.google.com/adwords/api/docs/reference/v201809/AdGroupCriterionService.ProductPartition#parentcriterionid
>
> ...whereas the report reference does not mention the root at all:
>
> https://developers.google.com/adwords/api/docs/appendix/reports/product-partition-report#parentcriterionid
>
> .Where('ParentCriterionId').In(None)
>
> ...throws an error.
>
> Or would you recommend using the AdGroupCriterionService for this task?
>
> Best regards
> Matthias
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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/a96f9575-5d9b-495f-a02d-d3704825eb40%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • ... Matthias Baader
    • ... Kevin Weitzner
      • ... 'Luis Xander Talag (AdWords API Team)' via AdWords API and Google Ads API Forum

Reply via email to