Multiple Metric Issue with HTTP API

21 views
Skip to first unread message

A

unread,
Jun 11, 2014, 5:27:03 PM6/11/14
to adsen...@googlegroups.com
I am trying to generate a report with multiple metrics but I keep receiving an empty report. I am using Ruby with HTTParty to use the v1.4 HTTP API. Am I supposed use a list for the metric parameters?

Here is my code: 

options = {
  query: {
    endDate: "2014-05-25",
    startDate: "2014-05-24",
    dimension: "AD_UNIT_NAME",
    metric: ["AD_REQUESTS","EARNINGS", "CLICKS"]
  },
  headers: {
    'Authorization' => 'Bearer %s' %token
  }
}

Thanks! 

Sérgio Gomes (AdSense API Team)

unread,
Jun 12, 2014, 5:21:44 AM6/12/14
to adsen...@googlegroups.com
Hi there,

I'm afraid I'm not familiar enough with HTTParty to give you an answer on that, but essentially, what you want to have at the HTTP level is metric=AD_REQUESTS&metric=EARNINGS&metric=CLICKS
In other HTTP clients, that's achieved by assigning an array to a key, as you mention, and the client handles the rest.

Could you take a look at the logs to see what your request string looks like?

Also, have you considered using the Google APIs client library instead? We've got a pretty good set of samples to get you started!

Cheers,
Sérgio

---
Sérgio Gomes
Developer Relations

Google UK Limited
Registered Office: Belgrave House, 76 Buckingham Palace Road, London SW1W 9TQ
Registered in England Number: 3977902
Reply all
Reply to author
Forward
0 new messages