0

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.

Shila Mosammami
  • 999
  • 6
  • 20
  • the error detail: { "code" : 400, "details" : [ { "@type" : "type.googleapis.com/google.rpc.BadRequest" } ], "errors" : [ { "domain" : "global", "message" : "Request contains an invalid argument.", "reason" : "badRequest" } ], "message" : "Request contains an invalid argument.", "status" : "INVALID_ARGUMENT" } – Shila Mosammami Mar 23 '22 at 15:06
  • Could you try issuing the request via the OAuth playground (https://developers.google.com/my-business/content/basic-setup#make-simple-http-request)? The Java client libary currently does not offer the detailed error information that the API would actually return. – vpgcloud Mar 23 '22 at 15:33
  • @vpriesner thanks a million , the error is "fieldViolations": [ { "field": "read_mask", "description": "Field is required" } but what are all possible read_mask? – Shila Mosammami Mar 23 '22 at 15:44
  • Ok I understood, just like locations list. String readMask="storeCode,regularHours,name,languageCode,title,phoneNumbers,categories,storefrontAddress,websiteUri,regularHours,specialHours,serviceArea,labels,adWordsLocationExtensions,latlng,openInfo,metadata,profile,relationshipData,moreHours"; – Shila Mosammami Mar 23 '22 at 15:48

1 Answers1

1

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);
   }
Shila Mosammami
  • 999
  • 6
  • 20