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

Which user account information is specifically required in the query for getting location via API?

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hello to the Google My Business API team and thanks a bunch for your help in advance.

My question relates specifically to best practices regarding querying for locations (using API 3.0+). I know that in order to request a location, I can make the following query:

GET https://mybusiness.googleapis.com/v3/{name=accounts/*/locations/*}

From what I understand, that last part in the brackets is replaced with the full name of my location, which has both the id ("name") of both an account and a location. 

What I'd like to ask is: which account name am I obligated to provide in order to query for a certain location? Although I know that there can be several accounts that manage one business, and I assume any of them can be passed in the above query as long as your access token allows access, I've also been able to get a successful response when passing the name of a seemingly unrelated account, or even by sometimes entering a random string of numbers.

If you can understand how it's not clear to me exactly which accounts will give you "access" to querying for a location by its name and which do not, I would greatly appreciate some guidelines on the topic as I have found the GMB API v 3.0 docs a bit lacking.

Thanks!

Philip

2 Expert replyverified_user

Which user account information is specifically required in the query for getting location via API?

Top Contributor
# 2
Top Contributor

I've also been able to get a successful response when passing the name of a seemingly unrelated account, or even by sometimes entering a random string of numbers.

 

Have you been able to access listings in accounts that you can't authenticate? 



Joel Headley, Google My Business Top Contributor
Find me on: Twitter

Which user account information is specifically required in the query for getting location via API?

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Hi, no I haven't been able to access unauthenticated listings. Just the ones I am allowed access to via my access token. But what is implied by the fact that I can access them by providing almost any arbitrary string as my account name? Is the account name relevant to my query at all?

Which user account information is specifically required in the query for getting location via API?

Top Contributor
# 4
Top Contributor

Interesting - when I pass an arbitrary string as the account name, I get a 404 - not found response. What kind of queries are you doing that seem to ignore the account name?

 

Specifically, I tried the GET you posted above and the 404 response is returned. 



Joel Headley, Google My Business Top Contributor
Find me on: Twitter

Re: Which user account information is specifically required in the query for getting location via AP

Google Employee
# 5
Google Employee

Hi @Philip K,

 

The request query you mentioned in your post should contain accountId and locationId.

GET https://mybusiness.googleapis.com/v3/accounts/account_name/locations/locationId

 

Please follow the steps below to know how to access accounts and locations using Google My Business API:

 

1. Create an account: You will be able to read business accounts using the API, but will not be able to create them. To create a business account, you must log into the Google My Business interface.

 

2. Once you have created your account(s), you can get a list of all your accounts by sending a GET request in OAuth 2.0 Playground via Google My Business API.             

GET https://mybusiness.googleapis.com/v3/accounts

 

3. Each account contains account_id so you will be able to identify which account you want to use for retrieving your locations.

 

4. You can get the list of locations for the specified account by sending a GET request:          

GET https://mybusiness.googleapis.com/v3/accounts/account_name/locations

 

5. Get the specified location. If the location does not exist, it returns NOT_FOUND. Please note, the account_name is an accountId. 

GET https://mybusiness.googleapis.com/v3/accounts/account_name/locations/locationId

 

We suggest you please Make a simple HTTP request step-by-step guide on the Google Developers site to learn how 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