My Business
3.6K members online now
3.6K members online now
For developers who are using the Google My Business API to manage locations
Guide Me
star_border
Reply

Invalid JSON payload received - Unknown name "location_name": Cannot find field.

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I'm able to list the location using List<Location> locations = response.getLocations();

I can also print the pretty name as ;

for (Location location :locations) {
                System.out.println("Pretty Location" + location.toPrettyString());

}

 

Her I can see the locationName, storeCode fields. But I cannot filter out the results using the below code.

 

BatchGetLocationsRequest batchGetLocationsRequest = new BatchGetLocationsRequest();
        batchGetLocationsRequest.set("locationName", "My Location");


        MyBusiness.Accounts.Locations.BatchGet locations = mybusiness.accounts().locations().batchGet(accountName, batchGetLocationsRequest);
        locations.getRequestHeaders().set("X-GOOG-API-FORMAT-VERSION", 2);
        BatchGetLocationsResponse response = locations.execute();

 

I also tried using

batchGetLocationsRequest.set("storeCode", "My Location");

 

I get 400 suggesting unknown name location_name & store_code

This is the full stack trace I see :

Exception in thread "main" com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
  "code" : 400,
  "message" : "Invalid JSON payload received. Unknown name \"location_name\": Cannot find field.",
  "status" : "INVALID_ARGUMENT",
  "details" : [ {
    "@type" : "type.googleapis.com/google.rpc.BadRequest",
    "fieldViolations" : [ {
      "description" : "Invalid JSON payload received. Unknown name \"location_name\": Cannot find field."
    } ]
  } ]
}
    at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:146)
    at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
    at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:321)
    at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1065)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)

 

 

 

1 Expert replyverified_user

Re: Invalid JSON payload received - Unknown name "location_name": Cannot find field.

Google Employee
# 2
Google Employee

Hi @A K I,

 

The error you mentioned in your post indicates that your are using incorrect value for the locationName. Make sure you are using locationid instead of locationname in your code when using the Google My Business API. Please try making these changes in your code and do let us know if you are still getting the same error.

 

Thanks,

The Google My Business API team