I'm trying to fetch a very simple data set from a google analytics report and haven't gotten it to authenticate. I'm really lost. I've been using the APIs explorer to test what I'm trying to do out and can't seem to do a simple batch get. I've blanked out the key field (obv)
This is basically what I'm trying to get to send back: Services > Google Analytics Reporting API v4 > analyticsreporting.reports.batchGet
Note: I'm not trying to do OAuth2 but just fire this stuff with a server API key.
POST https://analyticsreporting.googleapis.com/v4/reports:batchGet?fields=reports&key=XXX
{
"reportRequests": [
{
"dateRanges": [
{
"startDate": "2014-06-23",
"endDate": "2016-06-23"
}
],
"orderBys": [
{
"fieldName": "ga:pageviews",
"sortOrder": "DESCENDING"
}
],
"dimensions": [
{
"name": "ua:page"
}
]
},
{
"viewId": "7070072"
}
]
}
This is what comes back:
{
"error": {
"code": 401,
"message": "The request does not have valid authentication credentials.",
"status": "UNAUTHENTICATED"
}
}