Multiple metrics per request

36 views
Skip to first unread message

Toruk Makhto

unread,
May 7, 2012, 4:00:46 AM5/7/12
to AdSense API Forum
Hi,

I'd like to know if there is a way to get more than one metric from a
single API call. I'd
like to get around 5-10 metrics in a single request itself so that I
don't waste requests/bandwidth.
I tried the following url in the api playground

https://www.googleapis.com/adsense/v1.1/reports?endDate=2012-05-07&startDate=2012-05-07&metric=PAGE_VIEWS,EARNINGS

and got the following response

HTTP/1.1 400 Bad Request
status: 400
content-length: 419
x-xss-protection: 1; mode=block
x-content-type-options: nosniff
x-google-cache-control: remote-fetch
expires: Mon, 07 May 2012 07:52:12 GMT
server: GSE
via: HTTP/1.1 GWA
cache-control: private, max-age=0
date: Mon, 07 May 2012 07:52:12 GMT
x-frame-options: SAMEORIGIN
content-type: application/json; charset=UTF-8
-content-encoding: gzip

{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalidParameter",
"message": "Invalid value 'PAGE_VIEWS,EARNINGS'. Values must match
the following regular expression: '[a-zA-Z_]+'",
"locationType": "parameter",
"location": "metric[0]"
}
],
"code": 400,
"message": "Invalid value 'PAGE_VIEWS,EARNINGS'. Values must match
the following regular expression: '[a-zA-Z_]+'"
}
}

If anyone knows of a solution, please do let me know.

Thanks.

Toruk Makhto

unread,
May 7, 2012, 2:19:03 PM5/7/12
to adsen...@googlegroups.com
Hi,

Nevermind, I figured it out, I had to simply append multiple metric parameters to the url like for example

https://www.googleapis.com/adsense/v1.1/reports?endDate=2012-05-07&metric=EARNINGS&metric=PAGE_VIEWS&startDate=201-05-07

shan...@gmail.com

unread,
Jun 26, 2013, 10:31:39 AM6/26/13
to adsen...@googlegroups.com
Thank you - this helped me out too!
Reply all
Reply to author
Forward
0 new messages