Closed voets closed 10 months ago
It's hard to tell without full context of what your script is doing. What I would suggest is start with the example exactly as we wrote it, confirm that that's working, and then re-implement your changes one at a time until you discover which step caused the issue. From there I may be able to provide more help or you may even figure it out yourself.
I'm also authenticating using a service account keyfile and getting the same error if I don't set the developer_token
. Do you need to set that even if you're using a service account?
Yes, developer token is always required.
Service account and/or refresh token authenticates that you are allowed to access the Google Ads account. Developer token authenticates that you are allowed to use the API.
Both are required for every request.
I'm starting out with Ads API , ruby client, to see if I can report offline conversions from our server to our google account. I've setup a service account and stored the credentials json file. I've modified this exampe script https://developers.google.com/google-ads/api/samples/get-ad-groups a little to use the json file as a keyfile
When running the script it raises the error: Header values must be of type string or array (ArgumentError)
Here are the results from the commandline: W, [2023-02-16T15:30:00.137367 #91412] WARN -- : CID: 3362200146, Host: googleads.googleapis.com:443, Method: /google.ads.googleads.v12.services.GoogleAdsService/Search, IsFault: yes, Request ID: N/A I, [2023-02-16T15:30:00.137681 #91412] INFO -- : Outgoing request: Headers: {"developer-token":"REDACTED","x-goog-api-client":"gl-ruby/2.7.7 gccl/20.0.0 gax/0.17.1 gapic/20.0.0 grpc/1.52.0 pb/3.21.12","x-goog-request-params":"customer_id=3362200146"} Payload: {"customerId":"3362200146","query":"SELECT campaign.id, ad_group.id, ad_group.name FROM ad_group","pageSize":1000} I, [2023-02-16T15:30:00.137758 #91412] INFO -- : Incoming response (errors): ArgumentError(Header values must be of type string or array): called from: script/google_test2.rb:23:in
get_ad_groups' Traceback (most recent call last): 27: from bin/rails:4:in
' 26: from bin/rails:4:inrequire' 25: from /usr/local/lib/ruby/gems/2.7/gems/railties-6.1.3.2/lib/rails/commands.rb:18:in
' 24: from /usr/local/lib/ruby/gems/2.7/gems/railties-6.1.3.2/lib/rails/command.rb:50:ininvoke' 23: from /usr/local/lib/ruby/gems/2.7/gems/railties-6.1.3.2/lib/rails/command/base.rb:69:in
perform' 22: from /usr/local/lib/ruby/gems/2.7/gems/thor-1.2.1/lib/thor.rb:392:indispatch' 21: from /usr/local/lib/ruby/gems/2.7/gems/thor-1.2.1/lib/thor/invocation.rb:127:in
invoke_command' 20: from /usr/local/lib/ruby/gems/2.7/gems/thor-1.2.1/lib/thor/command.rb:27:inrun' 19: from /usr/local/lib/ruby/gems/2.7/gems/railties-6.1.3.2/lib/rails/commands/runner/runner_command.rb:42:in
perform' 18: from /usr/local/lib/ruby/gems/2.7/gems/railties-6.1.3.2/lib/rails/commands/runner/runner_command.rb:42:inload' 17: from script/google_test2.rb:51:in
' 16: from script/google_test2.rb:23:inget_ad_groups' 15: from /usr/local/lib/ruby/gems/2.7/gems/google-ads-googleads-20.0.0/lib/google/ads/google_ads/service_wrapper.rb:50:in
method_missing' 14: from /usr/local/lib/ruby/gems/2.7/gems/google-ads-googleads-20.0.0/lib/google/ads/google_ads/service_wrapper.rb:50:inpublic_send' 13: from /usr/local/lib/ruby/gems/2.7/gems/google-ads-googleads-20.0.0/lib/google/ads/google_ads/v12/services/google_ads_service/client.rb:263:in
search' 12: from /usr/local/lib/ruby/gems/2.7/gems/gapic-common-0.17.1/lib/gapic/grpc/service_stub.rb:156:incall_rpc' 11: from /usr/local/lib/ruby/gems/2.7/gems/gapic-common-0.17.1/lib/gapic/grpc/service_stub/rpc_call.rb:123:in
call' 10: from /usr/local/lib/ruby/gems/2.7/gems/grpc-1.52.0/src/ruby/lib/grpc/generic/client_stub.rb:173:inblock in request_response' 9: from /usr/local/lib/ruby/gems/2.7/gems/grpc-1.52.0/src/ruby/lib/grpc/generic/interceptors.rb:175:in
intercept!' 8: from /usr/local/lib/ruby/gems/2.7/gems/google-ads-googleads-20.0.0/lib/google/ads/google_ads/interceptors/logging_interceptor.rb:53:inrequest_response' 7: from /usr/local/lib/ruby/gems/2.7/gems/grpc-1.52.0/src/ruby/lib/grpc/generic/interceptors.rb:177:in
block in intercept!' 6: from /usr/local/lib/ruby/gems/2.7/gems/grpc-1.52.0/src/ruby/lib/grpc/generic/interceptors.rb:175:inintercept!' 5: from /usr/local/lib/ruby/gems/2.7/gems/google-ads-googleads-20.0.0/lib/google/ads/google_ads/interceptors/error_interceptor.rb:65:in
request_response' 4: from /usr/local/lib/ruby/gems/2.7/gems/grpc-1.52.0/src/ruby/lib/grpc/generic/interceptors.rb:181:inblock in intercept!' 3: from /usr/local/lib/ruby/gems/2.7/gems/grpc-1.52.0/src/ruby/lib/grpc/generic/interceptors.rb:178:in
block (2 levels) in intercept!' 2: from /usr/local/lib/ruby/gems/2.7/gems/grpc-1.52.0/src/ruby/lib/grpc/generic/client_stub.rb:174:inblock (2 levels) in request_response' 1: from /usr/local/lib/ruby/gems/2.7/gems/grpc-1.52.0/src/ruby/lib/grpc/generic/active_call.rb:373:in
request_response' /usr/local/lib/ruby/gems/2.7/gems/grpc-1.52.0/src/ruby/lib/grpc/generic/active_call.rb:373:in `run_batch': Header values must be of type string or array (ArgumentError)I'm using ruby 2.7 as you can see, with rails 6.1.3.2 on FreeBSD 12.4-RELEASE r372781
The request headers show up as a hash in the logging, but all key/value header pairs look fine to me. So I hope you can tell me what is going wrong here , since I have no clue what could be causing this