Getting Error in KeywordPlanIdeaServiceClient when send more than 20 Keywords in Request

527 views
Skip to first unread message

BD

unread,
Mar 25, 2022, 8:29:56 AM3/25/22
to Google Ads API and AdWords API Forum
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);
}

Google Ads API Forum Advisor

unread,
Mar 25, 2022, 3:48:47 PM3/25/22
to badar.ma...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for reaching out to us.

To investigate the issue further, could you please provide the complete request and response logs, with the request-id? If you haven't yet, logging can be enabled by navigating to the Client libraries > Your client library (ex. Java) > Logging documentation, which you can access from this link. You can provide it via Reply privately to author option. If this option is not available, then send it instead on this email address googleadsa...@google.com.

Thanks,

Google Logo
Nirmita
Google Ads API Team
 


 

ref:_00D1U1174p._5004Q2YrP99:ref

Badar Maqsood

unread,
Apr 12, 2022, 6:40:01 AM4/12/22
to ads...@forumsupport.google, adwor...@googlegroups.com
Hi Concerned,

I have checked other threads and its confirmed that the issue is there. API allows 20 Keywords per call and one call per second.

In the following thread a Google Ads respondent has confirmed it.


They have also asked to use the following track to accomplish the task

1. Create a KeywordPlan.
2. Create a KeywordPlanCampaign.
3. Create a KeywordPlanAdGroup.
4. Put the keywords in the above KeywordPlanAdGroup.

and then pull the data.

Although I dont have and dont need Plan/Campaign/AdGroup but still I created these. This does not solve the problem as "Resource Exhausted" error occurs.

Please guide how to use this Keyword Ideas API "KeywordPlanIdeaServiceClient" if

1. We can send 1 request per second.
2. We can send only 20 keywords in one request.

How will the applications run that used to depend upon TargetIDeasService?

Please respond in detail what should be done?

Google Ads API Forum Advisor

unread,
Apr 12, 2022, 4:08:25 PM4/12/22
to badar.ma...@gmail.com, adwor...@googlegroups.com
Hi BD,

Thank you for reaching out to the Google Ads API support team.

Could you please confirm are you using  AdWords API or Google Ads API? If you are using Adwords API,  could you please share complete SOAP logs (request and response with requestId)?

If you are using Google Ads API,could you provide us with the complete request and response logs with the request-id generated where we can see the RESOURCE_EXHAUSTED errors, so our team can check better? You can refer to this guide, as well as this section, for more information. The planning services feature is following the 1 QPS is calculated as 60 requests per 60 seconds limit

Please note that the AdWords API is deprecated and will sunset on April 27, 2022. We strongly recommend that you migrate to the Google Ads API as soon as possible.

If you’re using a client library, logging can be enabled by navigating to the Client libraries > Your client library (ex. Java) > Logging documentation, which you can access from this link

You may then send the requested information via the Reply privately to author option. If this option is not available, you may send the details directly to our googleadsa...@google.com alias instead by adding reference of this thread. 


Thanks,
Google Logo
Nirmita
Google Ads API Team
 

 

ref:_00D1U1174p._5004Q2a2IIX:ref
Reply all
Reply to author
Forward
0 new messages