this is an update to an earlier question I had posted that was incomplete
and i deleted
I'm trying the following code from the C# example library but getting
connection errors which I thing is due to the correct parameters not being
passed
1- am I passing the customerId correctly? (the account I am trying to
read)? the long.Parse("123-456-7890") gives an error
(why is this converted to long when it is converted back to a string when
it is used in Run?)
2 - Should the 'client' include the AdWordsAPI parameters from the
app.config ? I have the correct data in the app.config but when debugging
the config section for client only shows defaults for some fields and empty
strings for the developerToken, etc
3 - if this is correct how do I fix it?
public static void Main(string[] args)
{
GetCampaigns codeExample = new GetCampaigns();
Console.WriteLine(codeExample.Description);
// The Google Ads customer ID for which the call is made.
long customerId = 1327758399;//
long.Parse("INSERT_CUSTOMER_ID_HERE");
codeExample.Run(new GoogleAdsClient(), customerId);
Console.Read();
}
public void Run(GoogleAdsClient client, long customerId)
{
// Get the GoogleAdsService.
GoogleAdsServiceClient googleAdsService =
client.GetService(Services.V1.GoogleAdsService);
// Create a request that will retrieve all campaigns using
pages of the specified
// page size.
SearchGoogleAdsRequest request = new SearchGoogleAdsRequest()
{
PageSize = PAGE_SIZE,
Query = @"SELECT
campaign.id,
campaign.name,
campaign.network_settings.target_content_network
FROM campaign
ORDER BY campaign.id",
CustomerId = customerId.ToString()
};
try
{
// Issue the search request.
PagedEnumerable<SearchGoogleAdsResponse, GoogleAdsRow>
searchPagedResponse =
googleAdsService.Search(request);
foreach (SearchGoogleAdsResponse response in
searchPagedResponse.AsRawResponses())
{
Console.WriteLine(response.FieldMask.Paths);
foreach (GoogleAdsRow googleAdsRow in response.Results)
{
Console.WriteLine("Campaign with ID {0} and name
'{1}' was found.",
googleAdsRow.Campaign.Id,
googleAdsRow.Campaign.Name);
}
}
// Iterate over all rows in all pages and prints the
requested field values for the
// campaign in each row.
foreach (GoogleAdsRow googleAdsRow in searchPagedResponse)
{
Console.WriteLine("Campaign with ID {0} and name '{1}'
was found.",
googleAdsRow.Campaign.Id,
googleAdsRow.Campaign.Name);
}
}
catch (GoogleAdsException e)
{
Console.WriteLine("Failure:");
Console.WriteLine($"Message: {e.Message}");
Console.WriteLine($"Failure: {e.Failure}");
Console.WriteLine($"Request ID: {e.RequestId}");
}
}
.
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 [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 and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/ad09bed1-136b-486c-96f5-152c931b32b1%40googlegroups.com.