Hi Daniel,

Account label filtering in the AdWords API is based on the AccountLabel id 
<https://developers.google.com/adwords/api/docs/reference/v201506/ManagedCustomerService.AccountLabel#id>
 rather 
than the name. Therefore, if you create a predicate using the 
*AccountLabels* field, *CONTAINS_ANY* or *CONTAINS_ALL*, and the 
*AccountLabel* IDs, it should work as expected.

<ns10:predicates 
xmlns:ns10="https://adwords.google.com/api/adwords/cm/v201506";>
    <ns10:field>AccountLabels</ns10:field>
    <ns10:operator>CONTAINS_ANY</ns10:operator>
    <ns10:values>4099876</ns10:values>
    <ns10:values>4099899</ns10:values>
</ns10:predicates>

To get the list of available account labels and their IDs, you can use 
AccountLabelService.get 
<https://developers.google.com/adwords/api/docs/reference/v201506/AccountLabelService#get>
.

Cheers,
Josh, AdWords API Team

On Wednesday, August 26, 2015 at 3:15:28 PM UTC-4, Daniel Alvarado wrote:
>
> Hi Team, 
>
> I'm trying to pull a simple report that gets performance data for a 
> sub-section of our accounts based on a given label. However, I'm having a 
> terrible time figuring out how to setup the Predicate correctly, as 
> anything I try results in 
>
> [InternalApiError.UNEXPECTED_INTERNAL_API_ERROR @ com.google.ads.api.
> services.common.error.InternalApiError.<init>(InternalApiErro]
>
> $user = $this->user;
> //Reset to the main MCC
> $user->SetClientCustomerId(AWHelper::$MASTER_CLIENT_ID);
> // Get the service, which loads the required classes.
> $managedCustomerService =
>     $user->GetService('ManagedCustomerService', 
> AWHelper::$ADWORDS_VERSION);
> // Create selector.
> $selector = new Selector();
> // Specify the fields to retrieve.
> $selector->fields = array('AccountLabels','CustomerId',  'Name', 
> 'CanManageClients', 'CurrencyCode');
> $predicate = new Predicate();
> $predicate->field = 'AccountLabels';
> $predicate->operator = 'CONTAINS_ANY';
> $predicate->values = array($labelName);
> $selector->predicates = array($predicate);
> // Make the get request.
> $graph = $managedCustomerService->get($selector);
> // Display serviced account graph.
> if (isset($graph->entries)) {
>     $accounts = array();
>     foreach ($graph->entries as $account) {
>         //Only include non-manager accounts
>         if (!$account->canManageClients) {
>             $accounts[$account->customerId] = $account;
>         }
>     }
>     return $accounts;
> } else {
>     return null;
> }
>
> I've also tried a few combinations for the predicate such as: 
>
> $predicate = new Predicate();
> $predicate->field = 'AccountLabels';
> $predicate->operator = 'IN';
> $predicate->values = array($labelName);
>
> and
>
> $predicate = new Predicate();
> $predicate->field = 'AccountLabels';
> $predicate->operator = 'EQUALS';
> $predicate->values = $labelName;
>
> Be advised, I'm trying to filter by Label Name, as I don't know what the 
> Label IDs are. 
>
> Any help is appreciated. 
>
> Thanks, 
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
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 Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at http://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/a4d66697-1400-4269-bfec-72027b729d7d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to