googleads/google-ads-dotnet

KeywordPlanIdeaServiceClient V12 works in Console application but not in ApiController

Closed this issue · 2 comments

We are using KeywordPlanIdeaServiceClient V10 and now were upgrading our solution to V12. This is the extracted chunk of code from our application.

public string Post(bool bIsCalledFromOutside = false)
{
string strKeywords = "";
try
{
GoogleAdsClient client = new GoogleAdsClient();

	KeywordPlanIdeaServiceClient keywordPlanIdeaService =
		client.GetService(Services.V12.KeywordPlanIdeaService);

	GenerateKeywordIdeasRequest request = new GenerateKeywordIdeasRequest()
	{
		CustomerId = "XXXXXXXXXXX"
	};

	var kArray = new string[] { "USA" };
	request.KeywordSeed = new KeywordSeed();
	request.KeywordSeed.Keywords.AddRange(kArray);

	request.Language = ResourceNames.LanguageConstant(1000);

	request.GeoTargetConstants.Add(ResourceNames.GeoTargetConstant(2840));

	request.KeywordPlanNetwork = KeywordPlanNetwork.GoogleSearchAndPartners;

	var response = keywordPlanIdeaService.GenerateKeywordIdeas(request);		

	foreach (GenerateKeywordIdeaResult result in response)
	{
		strKeywords += result.Text;
	}
	
	return strKeywords;
}
catch(Exception ex)
{

}

return strKeywords;

}

The code is currently working fine in an ApiController using V10. When we upgrade it to V11 it works fine but once we move to V12 it just hangs on the foreach statement.

We did some testing in a Console application and it works fine in while using V12.

Any ideas as to what is the problem when we use V12 in ApiController ?