javagoogle-my-business-apigoogle-my-business

how to get google-updated version of the specified location in mybusinessbusinessinformation.googleapis using java


Suppose mybusiness is an initializer of type MyBusinessBusinessInformation which also takes care of credentials, and locationName is a String which refers to the specific location and its format is locations/XXXXXXX. I am using this link

   try {

         MyBusinessBusinessInformation.Locations.GetGoogleUpdated updateList=mybusiness.locations().getGoogleUpdated(locationName);                     
           GoogleUpdatedLocation response = updateList.execute();
          if(response!=null && !response.isEmpty()) {
                               System.out.println(response.toString());
                           }
   }catch(Exception e){
     System.out.println(e);
   }

The error is

com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request

Thank you in advance.


Solution

  • Thanks to @Vprienser I found out the read_mask is obligatory.

    String readMask="storeCode,regularHours,name,languageCode,title,phoneNumbers,categories,storefrontAddress,websiteUri,regularHours,specialHours,serviceArea,labels,adWordsLocationExtensions,latlng,openInfo,metadata,profile,relationshipData,moreHours";
    
       try { 
            MyBusinessBusinessInformation.Locations.GetGoogleUpdated updateList=mybusiness.locations()
                                       .getGoogleUpdated(locationName).setReadMask(readMask);
                                    
             GoogleUpdatedLocation response = updateList.execute();
                               
            if(response!=null && !response.isEmpty()) {
                   System.out.println(response.toString());
               }
       }catch (Exceptions e){
        System.out.println(e);
       }