select from video resource with some segments cause GRPC::InvalidArguments error

59 views
Skip to first unread message

Yuichiro Honda

unread,
Mar 27, 2020, 4:23:24 AM3/27/20
to AdWords API and Google Ads API Forum
Hi. I tried to get video metrics using google-ads-ruby. I followed this doc:

and built query like this:
require_relative './collector'
require 'google/ads/google_ads'

client = Google::Ads::GoogleAds::GoogleAdsClient.new(Dir.pwd + "/google_ads_config.rb")

query = <<~QUERY
SELECT
metrics.conversions,
video.id
FROM
video
WHERE
segments.conversion_action_category = PAGE_VIEW
QUERY

customer_id = "MY_CUSTOMER_ID"

responses = client.service.google_ads.search_stream(customer_id, query)
responses.each do |response|
begin
response.results.each do |row|
metrics = row.metrics
video = row.video
puts "video.id: #{video.id}, metrics.conversions: #{metrics.conversions}"
end
end
end

but running this code causes GRPC error:
/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/grpc-1.27.0-universal-darwin/src/ruby/lib/grpc/generic/active_call.rb:31:in `check_status': 3:Request contains an invalid argument. (GRPC::InvalidArgument)

additional info:
  • Removing WHERE clause successfully returns row.
  • All of these segments cause same InvalidArgument error:
    • segments.ad_network_type
    • segments.click_type
    • segments.conversion_action
    • segments.conversion_action_category
    • segments.conversion_action_name

I want to use these all segments to analyze video ads more in detail.
Any idea?

Google Ads API Forum Advisor Prod

unread,
Mar 27, 2020, 11:43:12 AM3/27/20
to yuichir...@kaizenplatform.com, adwor...@googlegroups.com
Hi Yuichiro,

Thank you for reaching out. If you want to filter by a segment, that segment must also be in your SELECT clause. For example, you should change your original query to:

 SELECT metrics.conversions, video.id, segments.conversion_action_category

  FROM video
  WHERE segments.conversion_action_category = PAGE_VIEW

Regards,
Mitchell
Google Ads API Team

ref:_00D1U1174p._5001UXWykq:ref
Message has been deleted

Yuichiro Honda

unread,
Mar 29, 2020, 9:50:11 AM3/29/20
to AdWords API and Google Ads API Forum
Hi Mitchell,
Thank you. Given query was OK.
But with metrics.cost_micros, I got GRPC::InvalidArgument error error again.

require_relative './collector'
require 'google/ads/google_ads'

client = Google::Ads::GoogleAds::GoogleAdsClient.new(Dir.pwd + "/google_ads_config.rb")

query = <<~QUERY
  SELECT
    metrics.conversions,
    metrics.cost_micros, 
    video.id,
    segments.conversion_action_category
  FROM
    video
  WHERE
    segments.conversion_action_category = PAGE_VIEW
QUERY

customer_id = "XXXXXXXXX"

responses = client.service.google_ads.search_stream(customer_id, query)
responses.each do |response|
  begin
    response.results.each do |row|
      metrics = row.metrics
      video = row.video
      segments = row.segments
      puts "video.id: #{video.id}, metrics.conversions: #{metrics.conversions}, metrics.cost_micros: #{metrics.cost_micros}, conversion_action_category: #{segments.conversion_action_category}"
    end
  end
end

/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/grpc-1.27.0-universal-darwin/src/ruby/lib/grpc/generic/active_call.rb:31:in `check_status': 3:Request contains an invalid argument. (GRPC::InvalidArgument)


Is there some fields combination that is not allowed?

Google Ads API Forum Advisor Prod

unread,
Mar 30, 2020, 12:06:01 PM3/30/20
to yuichir...@kaizenplatform.com, adwor...@googlegroups.com
Hi Yuichiro,

Unfortunately, metrics.cost_micros is not compatible with the segments.conversion_action_category field.

Yuichiro Honda

unread,
Mar 30, 2020, 10:21:20 PM3/30/20
to AdWords API and Google Ads API Forum
Hi Mitchell,

Thank you. How do I know one segments is not compatible with some metrics?
Returned error always simply says GRPC::InvalidArgument and no detailed information.

Yuichiro

Google Ads API Forum Advisor Prod

unread,
Mar 31, 2020, 9:16:25 AM3/31/20
to yuichir...@kaizenplatform.com, adwor...@googlegroups.com
Hi Yuichiro,

You can enable detailed error logging as explained here which will let you know if the metrics aren't compatible. Additionally, you can use the AdWords documentation as a reference. For example, you can see here under "Not compatible with the following fields:" what isn't compatible with conversion category. There are some differences between AdWords API and Google Ads API but that would be a good place to start if you're confused.
Reply all
Reply to author
Forward
0 new messages