AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

My Business
4.8K members online now
4.8K 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 ]
Follower ✭ ☆ ☆
# 1
Follower ✭ ☆ ☆

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?

Follower ✭ ☆ ☆
# 3
Follower ✭ ☆ ☆

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

[ Edited ]
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/v4/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/v4/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/v4/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/v4/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

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

Visitor ✭ ✭ ✭
# 6
Visitor ✭ ✭ ✭

Hi Shalini,

 

I am trying to test GMB Api through Postman but unable to pass the appropriate scope for the same.

 

API :  https://mybusiness.googleapis.com/v4/accounts 

 

Please guide the scope name to pass to get the response.

Capture_gmbapi.PNGPostman Snapshot

 

 

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

Google Employee
# 7
Google Employee

Hi @prTechnologies C,

 

For the Google My Business API, the scope is: https://www.googleapis.com/auth/plus.business.manage

 

For Google My Business API, we recommend using the OAuth 2.0 Playground to experiment with the Google My Business API. Since the Google My Business API is not public, there are a few extra steps you'll need to take. You will need a client ID for a web application to proceed.

 

Please follow the Make a simple HTTP request step on the Get Started page of the documentation website for more information on how to use the OAuth 2.0 Playground to experiment with the Google My Business API.

 

If you have any additional questions for me, please feel free to let me know and I'd be happy to further assist!

 

Thanks,

Shalini

The Google My Business API team

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

Visitor ✭ ✭ ✭
# 8
Visitor ✭ ✭ ✭

Hi. I've followed all of the steps outlined in the links in this post and everything works fine except when I get to the last step and GET the request URI https://mybusiness.googleapis.com/v3/accounts - that returns:

 

{
 
"error": {
   
"status": "NOT_FOUND",
   
"message": "Method not found.",
   
"code": 404
 
}
}

 

Can you please assist?

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

Google Employee
# 9
Google Employee

Hi @Jason R,

 

The 404 Method not found error typically happens when you are using a different Project ID from the one we whitelisted for your company to access the Google My Business API.

 

I will reach out to you privately in a separate email thread for more details.

 

Thanks,

The Google My Business API team

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

Visitor ✭ ✭ ✭
# 10
Visitor ✭ ✭ ✭

I dont see google my business listed in the OAuth 2.0 playground?