My Business
5.3K members online now
5.3K members online now
For developers who are using the Google My Business API to manage locations
Guide Me
star_border
Reply

Report Insights Request - Error Message. What is wrong with my request?

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi, I'm using the provided C# library for GMB API. I've been able to authenticate and make requests to get my accounts and get the locations for each account. So, I don't have an authentication issue or issue with the compiled C# library

 

When I make the request to get report insights for 10 locations, I get this error:

Google.Apis.Requests.RequestError
Request contains an invalid argument. [400]
Errors [
Message[Request contains an invalid argument.] Location[ - ] Reason[badRequest] Domain[global]
]

 

I'm not sure where the "invalid argument" is. I tried using the Oauth playground to post the json serialized version of my request, and it said Oauth playground is not authorized to use the Google My Business API scope.

 

Could you help me determine what the issue is? There is not a lot of documentation or detail in the error message.

 

Here is my json ReportLocationsInsightsRequest, with all of the ids removed:

{"basicRequest":{"metricRequests":[{"metric":"ALL","options":["AGGREGATED_DAILY"],"ETag":null}],"timeRange":{"endTime":"2016-08-26T18:31:52.2811593Z","startTime":"2017-02-19T19:31:52.2811593Z","ETag":null},"ETag":null},"drivingDirectionsRequest":null,"locationNames":["accounts/{myaccountname}/locations/{locationname}","accounts/{myaccountname}/locations/{locationname}","accounts/{myaccountname}/locations/{locationname}","accounts/{myaccountname}/locations/{locationname}","accounts/{myaccountname}/locations/{locationname}","accounts/{myaccountname}/locations/{locationname}","accounts/{myaccountname}/locations/{locationname}","accounts/{myaccountname}/locations/{locationname}","accounts/{myaccountname}/locations/{locationname}","accounts/{myaccountname}/locations/{locationname}"],"ETag":null}

 

If you need my AccountsResource.LocationsResource.ReportInsightsRequest, I can get that to you as well.

 

Thank you for your help

 

 

1 Expert replyverified_user

Report Insights Request - Error Message. What is wrong with my request?

Visitor ✭ ✭ ✭
# 2
Visitor ✭ ✭ ✭

I changed the order of the dates in the timeRange and made the time range smaller, but that did not help.

Then, I changed the request to be for just one location. Same error.

 

Here is an example of a request with just 1 location and a smaller time range.

{
"basicRequest": {
"metricRequests": [{
"metric": "ALL",
"options": ["AGGREGATED_DAILY"],
"ETag": null
}],
"timeRange": {
"endTime": "2017-02-20T22:56:22.6695053Z",
"startTime": "2017-02-13T22:56:22.6695053Z",
"ETag": null
},
"ETag": null
},
"drivingDirectionsRequest": {
"languageCode": null,
"numDays": "SEVEN",
"ETag": null
},
"locationNames": ["accounts/{accountid}/locations/{locationid}"],
"ETag": null
}

Marked as Best Answer.
Solution
Accepted by topic author Scott J
February

Re: Report Insights Request - Error Message. What is wrong with my request?

Google Employee
# 3
Google Employee

Hi @Scott J,

 

There are couple of things that seems incorrect in your code:

 

   1. The values for timeRange of BasicMetricsRequest object are not correct. Start date must occur before end date.

 

   2. Remove ETag from your json code when using the OAuth 2.0 Playground to experiment with the Google My Business API. Please try to make these changes to see if it fixes your issue.

 

In addition, since the C# client library doesn’t currently support the display of detailed error messages, so it is always recommended to use the OAuth 2.0 Playground for troubleshooting errors with detailed error messages when sending requests with data via the Google My Business API.

 

Thanks,

The Google My Business API team