googleads / google-ads-dotnet

This project hosts the .NET client library for the Google Ads API.

Home Page:https://developers.google.com/google-ads/api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GoogleAdsService.Search() failure in upgrade from Library V11 / Ads V10 to V14 / Ads V11

tomsdavid opened this issue · comments

Hello - I have been communicating with the Google Ads API support team and they have asked me to contact you.

We have been using the API since 2014 with the same developer token and oAuth credentials / refresh token without problem. However, we have recently upgraded from the .NET client library V11 using Ads API V10 to .NET client library V14 with Ads API V11 and the call to GoogleAdsService.Search() is failing but without returning an error or logging information - configuration below:

  • .NET client library 14.0
  • VB.NET with .NET framework 4.8
  • Google Ads API v11
  • One method call to GoogleAdsService.Search()
  • Development token and Oath details used since 2014

I have attached an image of our code

  • As you can see, logging is enabled but the log DETAILED_REQUEST_LOGS_SOURCE is empty
  • However, the logging for GRPC does produce a file with data
  • The sample code performs a very simple campaign query
  • Line 57 calls GoogleAdsService.Search() successfully but...
  • When line 58 executes to read / fetch a result, the code runs but does not progress - it just sits there, waiting for something
  • And no exception is thrown, no logging is made
  • Please note that if a call is made to GoogleAdsService.SearchStream(), then the code executes correctly!

We are at a loss to work out what is happening as we cannot get any information from exceptions or logging. Could there be a problem with our OAuth desktop credentials or refresh token? Our "app" in Google Cloud Console is marked as "unverified", could this be a problem? (Although this has always been this way - we have one user of the app which is the MCC of the AdWords accounts we are accessing - which means we fit the "personal" user exception we think?)

Any help appreciated.
codep

Many thanks.

Hi Tom,

The Search call is heavy, and WinForm UI threads are not designed to handle heavy calls because the Message pump blocks or deadlocks with the awaiting tasks, You need to use the async methods, or do something like this:

Private Async Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  TraceUtilities.Configure(TraceUtilities.SUMMARY_REQUEST_LOGS_SOURCE,
      "c:\\Logs\\summary.log", System.Diagnostics.SourceLevels.All)

  TraceUtilities.Configure(TraceUtilities.DETAILED_REQUEST_LOGS_SOURCE,
      "c:\\Logs\\details.log", System.Diagnostics.SourceLevels.All)

  Dim client As New GoogleAdsClient
  Dim config As GoogleAdsConfig = client.Config

  config.DeveloperToken = "****"
  config.OAuth2Mode = OAuth2Flow.APPLICATION
  config.OAuth2ClientId = "****"
  config.OAuth2ClientSecret = "****"
  config.OAuth2RefreshToken = "****"
  config.LoginCustomerId = "****"

  Dim service = client.GetService(Services.V11.GoogleAdsService)
  Dim request As New SearchGoogleAdsRequest
  request.CustomerId = *****
  request.Query = "Select campaign.id, campaign.name from campaign"
  Await Task.Run(Sub() RunSearchQuery(service, request))
End Sub
Private Sub RunSearchQuery(service As GoogleAdsServiceClient, request As SearchGoogleAdsRequest)
  Dim results = service.Search(request)
  MsgBox("HERE " & results(0).Campaign.Name)
End Sub