-
Invalid JSON payload error when using Google Analytics 4
“Hey guys, need a bit of help here. So I’m playing around with Google Analytics API 4 and trying to get some data out. I’ve been doing this via Postman and here’s what I’ve done so far:
URL I’ve hit up:
https://analyticsreporting.googleapis.com/v4/reports:batchGet
and I’ve used the POST method. The body of the request looks like this:`
{
“reportRequests”: [
{
“viewId”: “376027054”,
“dateRanges”: [
{
“startDate”: “2023-01-03”,
“endDate”: “2023-01-0”
}
],
“pageSize”: 1,
“metrics”: [
{
“expression”: “ga:hits”
}
],
“dimensions”: [
{
“name”: “ga:date”
}
],
“segments”: [],
“filtersExpression”: “”
}
]
}
`
The response I got wasn’t what I was hoping for though. Received the “Invalid JSON payload received. Unexpected end of string. Expected an object key or} error. Here it is in all its glory:
`
{
“error”: {
“code”: 400,
“message”: “Invalid JSON payload received. Unexpected end of string. Expected an object key or }.nn^”,
“status”: “INVALID_ARGUMENT”
}
}
`
A little stuck on this one. Anyone have any idea what’s going wrong?”
Log in to reply.