AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

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

Field Mask issues & documentation

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

Hi,

 

I'm trying to update a location using the Java API as 

patchLocation.setFieldMask("store_code,primary_phone,address");

 

I get the below error : 

com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
"code" : 400,
"errors" : [ {
"domain" : "global",
"message" : "Request contains an invalid argument.",
"reason" : "badRequest"
} ],
"message" : "Request contains an invalid argument.",
"status" : "INVALID_ARGUMENT"
}
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)

 

But if I modify the code to remove 'address' as patchLocation.setFieldMask("store_code,primary_phone,address");

it works fine. 

 

I'm not sure what the mask for 'address' should be. Also is there any document which says what are the values for masks apart from 

https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldM...

 

I've still no idea how I came up with store_code for storeCode and primary_phone for primaryPhone.

1 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author Liam P
May 2017

Field Mask issues & documentation

Visitor ✭ ✭ ✭
# 2
Visitor ✭ ✭ ✭

Finally, I've found the way to do this. 

Changing to 

patchLocation.setLanguageCode("en").setFieldMask("storeCode,address,primaryPhone").getRequestHeaders().set("X-GOOG-API-FORMAT-VERSION", 2);

worked and also the header set gave appropriate error message which was easier to debug & fix

View solution in original post

Marked as Best Answer.
Solution
Accepted by topic author Liam P
May 2017

Field Mask issues & documentation

Visitor ✭ ✭ ✭
# 2
Visitor ✭ ✭ ✭

Finally, I've found the way to do this. 

Changing to 

patchLocation.setLanguageCode("en").setFieldMask("storeCode,address,primaryPhone").getRequestHeaders().set("X-GOOG-API-FORMAT-VERSION", 2);

worked and also the header set gave appropriate error message which was easier to debug & fix

Re: Field Mask issues & documentation

Google Employee
# 3
Google Employee

Hi @Liam P,

 

We're glad you found a solution. We suggest you always add this additional header to your requests to enable more detailed error messages in responses when using the Java client library:

X-GOOG-API-FORMAT-VERSION: 2

 

Please feel free to contact us for any Google My Business API related questions.

 

Thanks,

The Google My Business API team