The following C# code outputs a list of managed accounts. This works fine,
as it outputs all 50+ managed accounts (please read on)...
public static void AdWords_DisplayManagedCustomersToConsole()
{
// Create the user.
AdWordsUser user = new AdWordsUser();
(user.Config as AdWordsAppConfig).DeveloperToken = "(omitted)";
(user.Config as AdWordsAppConfig).OAuth2RefreshToken = "(omitted)";
(user.Config as AdWordsAppConfig).OAuth2ClientId = "(omitted)";
(user.Config as AdWordsAppConfig).OAuth2ClientSecret = "(omitted)";
(user.Config as AdWordsAppConfig).ClientCustomerId = "(omitted)";
// Create the service connector.
ManagedCustomerService managedCustomerService =
(ManagedCustomerService)user.GetService(AdWordsService.v201705.ManagedCustomerService);
// Create the selector.
Selector selector = new Selector();
selector.fields = new String[] { ManagedCustomer.Fields.CustomerId,
ManagedCustomer.Fields.Name };
selector.paging = Paging.Default;
// Create the page.
ManagedCustomerPage page = new ManagedCustomerPage();
// Try to get the customer list.
try
{
// Repeat the request until all pages are received.
do
{
// Get the campaigns.
page = managedCustomerService.get(selector);
// Display the results.
if (page != null && page.entries != null)
{
// Loop through all customers in this current page
int i = selector.paging.startIndex;
foreach (ManagedCustomer customer in page.entries)
{
// Output the login, customer id, and name to the console
Console.WriteLine($"{(i + 1).ToString()}) Customer with customerID =
'{customer.customerId.ToString()}' and name = '{customer.name}'" + " was
found.");
i++;
}
}
selector.paging.IncreaseOffset();
} while (selector.paging.startIndex < page.totalNumEntries);
// Output the totals
Console.WriteLine("Number of customers found: {0}", page.totalNumEntries);
}
catch (Exception ex)
{
// throw exception
throw new System.ApplicationException("Failed to retrieve managed
customers", ex);
}
}
However, the following C# code, which is nearly identical (all omitted data
is the same in both code samples). The only difference is that this code is
supposed to get a list of campaigns for one customer (the main customer
account) instead of a list of managed accounts. This does not work....
public static void AdWords_DisplayCampaignsToConsole(string customerID)
{
// Create the user.
AdWordsUser user = new AdWordsUser();
(user.Config as AdWordsAppConfig).DeveloperToken = "(omitted)";
(user.Config as AdWordsAppConfig).OAuth2RefreshToken = "(omitted)";
(user.Config as AdWordsAppConfig).OAuth2ClientId = "(omitted)";
(user.Config as AdWordsAppConfig).OAuth2ClientSecret = "(omitted)";
(user.Config as AdWordsAppConfig).ClientCustomerId = "(omitted)";
// Create the service connector.
CampaignService campaignService =
(CampaignService)user.GetService(AdWordsService.v201705.CampaignService);
// Create the selector.
Selector selector = new Selector();
selector.fields = new String[] { Campaign.Fields.Id, Campaign.Fields.Name,
Campaign.Fields.Status };
selector.paging = Paging.Default;
// Create the page.
CampaignPage page = new CampaignPage();
// Try to get the campaign list.
try
{
// Repeat the request until all pages are received.
do
{
// Get the campaigns.
page = campaignService.get(selector);
// Display the results.
if (page != null && page.entries != null)
{
// Loop through all campaigns in this current page
int i = selector.paging.startIndex;
foreach (Campaign campaign in page.entries)
{
// Output the compani id, name, and status to the console
Console.WriteLine($"{(i + 1).ToString()}) Campaign with id =
'{campaign.id.ToString()}', name = '{campaign.name}' and status =
'{campaign.status.ToString()}'" + " was found.");
i++;
}
}
selector.paging.IncreaseOffset();
} while (selector.paging.startIndex < page.totalNumEntries);
// Output the totals
Console.WriteLine("Number of campaigns found: {0}", page.totalNumEntries);
}
catch (Exception ex)
{
// throw exception
throw new System.ApplicationException("Failed to retrieve campaigns", ex);
}
}
There are no errors, but the results come back empty. No campaigns to list.
This is odd, because I'm looking at this customer account in the AdWords
web interface and I see lots of campaigns of all different types.
What could be allowing the first code block to produce results but not the
second code block? What am I missing here?
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 https://groups.google.com/group/adwords-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/edfad64f-fde8-4ae6-9587-fa1effa7ae41%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.