I'm try to send request for version 4 api I'm do this simple request
$.ajax({
url: 'https://analyticsreporting.googleapis.com/v4/reports:batchGet',
headers: {
"Authorization":"Bearer xxxx"
},
method:"POST",
data:{
"reportRequests":[
{
"viewId":"xxx",
"dateRanges":[
{
"startDate":"2015-06-15",
"endDate":"2015-06-30"
}],
"metrics":[
{
"expression":"ga:sessions"
}],
"dimensions": [
{
"name":"ga:browser"
}]
}]
},
success: function(resp){
alert(resp);
}
});
But it's return error.
"details": [
{
"@type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"description": "Invalid JSON payload received. Unknown name \"reportRequests[0][metrics][0][expression]\": Cannot bind query parameter. Field 'reportRequests[0][metrics][0][expression]' could not be found in request message."
},
{
"description": "Invalid JSON payload received. Unknown name \"reportRequests[0][dateRanges][0][endDate]\": Cannot bind query parameter. Field 'reportRequests[0][dateRanges][0][endDate]' could not be found in request message."
},
{
"description": "Invalid JSON payload received. Unknown name \"reportRequests[0][dimensions][0][name]\": Cannot bind query parameter. Field 'reportRequests[0][dimensions][0][name]' could not be found in request message."
},
{
"description": "Invalid JSON payload received. Unknown name \"reportRequests[0][dateRanges][0][startDate]\": Cannot bind query parameter. Field 'reportRequests[0][dateRanges][0][startDate]' could not be found in request message."
},
{
"description": "Invalid JSON payload received. Unknown name \"reportRequests[0][viewId]\": Cannot bind query parameter. Field 'reportRequests[0][viewId]' could not be found in request message."
}
]
}
]
What I'm do wrong?