I am trying to use GenerateKeywordIdeas method of 
KeywordPlanIdeaServiceClient service. It works fine if I send up to 20 
keywords in the request. If I send more than 20 keywords the code breaks 
down. The error I am getting is

Status(StatusCode="InvalidArgument", Detail="Request contains an invalid 
argument.", DebugException="Grpc.Core.Internal.CoreErrorDetailException: 
{"created":"@1648123856.780000000","description":"Error received from peer 
ipv4:216.58.201.74:443","file":"......\src\core\lib\surface\call.cc","file_line":1070,"grpc_message":"Request
 
contains an invalid argument.","grpc_status":3}")

I am using .Net Framework 4.7.2 and Google.Ads.GoogleAds 11.0.0.

Here is the code that I am using.

GoogleAdsConfig config = new GoogleAdsConfig()
{
        DeveloperToken = "**************",

        OAuth2ClientId = "**************",
        OAuth2ClientSecret = "**************",

        OAuth2RefreshToken = "**************"
};

GoogleAdsClient googleAdsClient = new GoogleAdsClient(config);

KeywordPlanIdeaServiceClient keywordPlanIdeaService = 
googleAdsClient.GetService(Services.V10.KeywordPlanIdeaService);

GenerateKeywordIdeasRequest request = new GenerateKeywordIdeasRequest()
{
        CustomerId = "**************",
};

//Keywords
request.KeywordSeed = new KeywordSeed();
//Language
request.Language = ResourceNames.LanguageConstant(1000);
//Location
request.GeoTargetConstants.Add(ResourceNames.GeoTargetConstant(2840));
//Network
request.KeywordPlanNetwork = KeywordPlanNetwork.GoogleSearchAndPartners;

request.KeywordSeed.Keywords.AddRange(new string[] {
        "ppc",
        "sun",
        "Moon",
        "cold",
        "night",
        "table",
        "golf",
        "cat",
        "dog",
        "animal food",
        "laptop",
        "desktop",
        "mouse",
        "bat",
        "hockey",
        "net",
        "shoe",
        "knife",
        "bag",
        "battery",
        "motorcycle",
        "pin",
        "chocolate"
});

try
{
        var response = keywordPlanIdeaService.GenerateKeywordIdeas(request);

        List<KeywordPlannerData> lstKeywordPlannerData = new 
List<KeywordPlannerData>();

        foreach (GenerateKeywordIdeaResult result in response)
        {
                KeywordPlannerData keywordPlannerData = new 
KeywordPlannerData()
                {
                        KeywordText = result.Text,
                        SearchVolume = (result.KeywordIdeaMetrics == null 
|| !result.KeywordIdeaMetrics.HasAvgMonthlySearches) ? 0 : 
result.KeywordIdeaMetrics.AvgMonthlySearches,
                        Competition = (result.KeywordIdeaMetrics == null) ? 
"0" : result.KeywordIdeaMetrics.Competition.ToString(),
                        LowTopOfPageBid = (result.KeywordIdeaMetrics == 
null || !result.KeywordIdeaMetrics.HasLowTopOfPageBidMicros) ? 0 : 
(double)(result.KeywordIdeaMetrics.LowTopOfPageBidMicros) / 1000000,
                        HighTopOfPageBid = (result.KeywordIdeaMetrics == 
null || !result.KeywordIdeaMetrics.HasHighTopOfPageBidMicros) ? 0 : 
(double)(result.KeywordIdeaMetrics.HighTopOfPageBidMicros) / 1000000
                };                

                lstKeywordPlannerData.Add(keywordPlannerData);
        }

        return lstKeywordPlannerData;

}
catch (GoogleAdsException e)
{
        throw new System.ApplicationException("Failed to validate 
keywords.", e);
}

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 
"Google Ads API and AdWords 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/1c0772a9-9c0b-4d08-b1fa-f4be61561819n%40googlegroups.com.

Reply via email to