Google My business API locations list request not returning all locations

Viewed 1386

I am making a locations list request to the Google My Business API and passing a given account id. The list method is supposed to return a list of all locations associated to the given id. The documentation can be found here https://developers.google.com/my-business/reference/rest/v4/accounts.locations/list. The response is returning a list of locations as expected however there are some locations that the account has access to that are missing from the list. I have tried to investigate to see if there are any factors that could be causing this such as verification status, missing store code, duplicate GMB location, who owns/manages the location. I have not found any factor that is the cause of the issue. Anyone have any insight?

2 Answers

There is a newer version of this API called mybusinessbusinessinformation, if you use a programming language to retrieve you would not have any problem to list all your locations, for example in java, suppose that mybusinessNotif is an initializer of type MyBusinessNotificationSettings which also takes care of credentials:

String readMask="storeCode,regularHours,name,languageCode,title,phoneNumbers,categories,storefrontAddress,websiteUri,regularHours,specialHours,serviceArea,labels,adWordsLocationExtensions,latlng,openInfo,metadata,profile,relationshipData,moreHours";
                    MyBusinessBusinessInformation.Accounts.Locations.List locationsList = mybusinessaccountLocations.accounts().locations().list(accountName).setReadMask(readMask);
                    ListLocationsResponse Response = locationsList.execute();
                    locations=Response.getLocations();

                    while (Response.getNextPageToken() != null) {
                        locationsList.setPageToken(Response.getNextPageToken());
                        Response=locationsList.execute();
                        locations.addAll(Response.getLocations());              
                    }

In fact using getNextPageToken() takes care of your problem.

Related