Creating an experiment with the ruby client

21 views
Skip to first unread message

Johnny

unread,
Jun 21, 2015, 9:47:18 AM6/21/15
to adwor...@googlegroups.com
I successfully created an experiment for my account. Now I'm trying to create an experiment with the ruby client library (the code I used is below). But I keep getting:

AdwordsApi::V201409::ExperimentService::ApiException: AdwordsApi::V201409::ExperimentService::ApiException
from /home/johnny/.rvm/gems/ruby-2.2.0/gems/google-ads-common-0.9.8/lib/ads_common/savon_service.rb:113:in `handle_errors'
from /home/johnny/.rvm/gems/ruby-2.2.0/gems/google-ads-common-0.9.8/lib/ads_common/savon_service.rb:83:in `execute_action'
from /home/johnny/.rvm/gems/ruby-2.2.0/gems/google-adwords-api-0.13.2/lib/adwords_api/v201409/experiment_service.rb:25:in `mutate'
from (irb):45
from /home/johnny/.rvm/rubies/ruby-2.2.0/bin/irb:11:in `<main>'

How do I interpret this error?

My code:

gem 'google-adwords-api', '0.13.2'
require 'adwords_api'
require 'time'

adwords = AdwordsApi::Api.new({ :authentication => { :method => 'OAuth2', :oauth2_client_id => 'client_id', :oauth2_client_secret => 'secret', :oauth2_callback => 'callback', :developer_token => 'sometoken', :user_agent => 'UA' }, :service => { :environment => 'PRODUCTION' } })

token = {:access_token=>"atoken", :refresh_token=>"rtoken", :issued_at=>Time.parse('2015-06-21 15:17:30'), :expires_in=>3600, :id_token=>nil}

adwords.credential_handler.set_credential(:oauth2_token, token)
adwords.credential_handler.set_credential(:client_customer_id, 'cid')

experiment_srv = adwords.service(:ExperimentService, API_VERSION)
operation = {   :operator => 'ADD',   :operand => {     :campaign_id => '11111111',     :name => "Interplanetary Experiment #%d" % (Time.new.to_f * 1000).to_i,     :query_percentage => 10,     :start_date_time => Time.now.strftime('%Y%m%d %H%M%S'),     :status => 'ENABLED',     :end_date_time =>        DateTime.parse((Date.today + 30).to_s).strftime('%Y%m%d %H%M%S')   } }
response = experiment_srv.mutate([operation])

Johnny

unread,
Jun 21, 2015, 10:01:07 AM6/21/15
to adwor...@googlegroups.com
Never mind. It turns out the service was temporarily unavailable. Would've been nice to get an error saying so, though...
Reply all
Reply to author
Forward
0 new messages