adsense.reports.generate is not allowing multiple values for metric attributes #35

Closed
sqrrrl opened this Issue Apr 8, 2013 · 2 comments

Comments

Projects
None yet
1 participant
Member

sqrrrl commented Apr 8, 2013

(Moved from https://code.google.com/p/google-api-ruby-client/issues/detail?id=69)

To reproduce

  1. authenticate via oauth 2
  2. use v1.2 (adsense.reports.generate)
  3. put multiple elements in array for metric attribute

What is the expected output? What do you see instead?
i expect all the metric attributes to appear with data,

instead i see no data at all, here's an example
when i put

'metric' => %w(CLICKS EARNINGS),

i get the following

"{\"kind\":\"adsense#report\",\"totalMatchedRows\":\"0\",\"headers\":[{\"name\":\"CUSTOM_CHANNEL_ID\",\"type\":\"DIMENSION\"}],\"totals\":[\"\"],\"averages\":[\"\"]}"

if i use only 1 element in metric, it works, for instance,

'metric' => %w(CLICKS),

i get the following

"{\"kind\":\"adsense#report\",\"totalMatchedRows\":\"2\",\"headers\":[{\"name\":\"CUSTOM_CHANNEL_ID\",\"type\":\"DIMENSION\"},{\"name\":\"CLICKS\",\"type\":\"METRIC_TALLY\"}],\"rows\":[[\"partner-pub-2227041865223506:1000000001\",\"112\"],[\"partner-pub-2227041865223506:1000000002\",\"89\"]],\"totals\":[\"\",\"201\"],\"averages\":[\"\",\"100\"]}"

im running on Centos 6, using gem 'google-api-client'

Member

sqrrrl commented Apr 8, 2013

Additional history:
Project Member #1 sbazyl@google.com
Likely caused by an issue with how Faraday encodes query parameters (https://github.com/technoweenie/faraday/issues/182.) A fix to Faraday was committed, but still waiting for them to cut a new gem with it included. Will verify once it is available.

Status: Accepted
Nov 12, 2012 Delete comment #2 michaelcni
Thanks
Jan 9, 2013 Delete comment #3 simoneau.louis
We've had to fork Faraday to get this working for us. With the new Faraday, you can use:

Faraday::Utils.default_params_encoder = Faraday::FlatParamsEncoder

to specify a parameter encoder that doesn't try to treat multiple occurrences of the same param as nested params and insert []. This required hacking the version number back to 0.8.x as both google-api-client and signet specifically depend on ~> 0.8.4 and ~> 0.8.1 respectively.

However, when the new Faraday is cut, if both of those other gems are updated to use Faraday 0.9.x, that line is all that's required to get things working.
Today (3 hours ago) Delete comment #4 damian.janowski
The new FlatParamsEncoder does indeed fix reports.

However, when Faraday 0.9 is released this option should be set at the APIClient level, that is, not changing the default behavior of Faraday.

Member

sqrrrl commented Jun 7, 2013

Fixed for 0.7 (soon)

@sqrrrl sqrrrl closed this Jun 7, 2013

@Kalmh Kalmh referenced this issue in google/google-api-nodejs-client Sep 26, 2014

Closed

Unable to set multiple dimension/metric to generate an adsense report #295

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment