简体   繁体   中英

Google My business API locations list request not returning all locations

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?

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.

I was facing a similar issue in Node.js environment.

Google Business Profile Api Method: accounts.locations.list

Although pageSize is set as 100 by default under Query Parameters in the documentation, if you do not define pageSize when requesting, you can get up to 10 locations. I was able to solve my problem by defining an optional pageSize.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM