When using the Google Business API to retrieve locations managed by the end user, I get a storeCode
. What I'm trying to do is check if that business location has a placeId
on Google Maps or not.
Before querying endpoints, I retrieve a token at this endpoint
https://www.googleapis.com/auth/business.manage
And then reuse the token for each call. Then list accounts at this endpoint
https://mybusinessaccountmanagement.googleapis.com/v1/accounts
When querying the locations associated with an account, I use the endpoint
https://mybusinessbusinessinformation.googleapis.com/v1/accounts/ACCOUNT_NUMBER/locations?readMask=name,title,storeCode,latlng
The documentation seems to imply that one can retrieve the Google Maps placeId by using the endpoint
https://mybusinessbusinessinformation.googleapis.com/v1/locations/LOCATION_NUMBER:googleUpdated?readMask=placeId
But when doing so, I get the error
Access to fetch at (...) has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I do not get this error with the previous endpoints/calls, just this last one. What's going on? Is this the proper way to retrieve the placeId ?
Update: Turns out after digging around, the documentation is wrong 😤
It's getGoogleUpdated
not googleUpdated
Now I don't get the CORS error anymore but that end point won't let me use placeId
in the readMask
.
So the question remains, how do I check via the Google Business Profile API if an end user managed business has a placeId in Google Maps or not ?
I will answer my own question : you can't query the field placeId
from the front-end lib. You need to call from a back-end and query to avoid CORS.
It also returns 404 instead of a valid JSON response if it does not find the placeId
(bruh what).
There also is no direct relation between storeCode
and placeId
(lol). Google will ingest "at some point" the location (if created from the Business API) into Maps so you periodically have to call the end point (from a back-end)
GET https://mybusinessbusinessinformation.googleapis.com/v1/{locationName}:googleUpdated?readMask=placeId
In order to check if it has made it to Google Maps (lmao). Absolutely ridiculous workflows.