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

V3 location.name problem on Updates (Patch)

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

While migrating from v2 to v3 of the GMB API I've noticed a weird behavior on updates. I can create a Location just fine, but then when I try to update the Location I am getting an error like the one below:


{
"code" : 400,
"message" : "Request contains an invalid argument.",
"status" : "INVALID_ARGUMENT",
"details" : [ {
"@type" : "type.googleapis.com/google.mybusiness.v3.ValidationError",
"errorDetails" : [ {
"code" : 7,
"field" : "location.name",
"message" : "location.name is invalid",
"value" : "accounts/100432101844292648828/locations/13379116126952436394"
} ]
} ]
}

 

The code is very similar to the v2 code, and looks something like this:

 

googleMyBusinessServiceFactory.getGoogleMyBusinessService(account)
.accounts().locations().patch(location.getName(), location).setLanguageCode(LANGUAGE_CODE)

 

Any ideas about what might be going on?

 

-Stephen

 

1 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author Stephen K
May 2016

Re: V3 location.name problem on Updates (Patch)

Google Employee
# 3
Google Employee

Hi @Stephen K,

 

The name field of a Location object is read-only for the version 3 (v3) of the Google My Business API. You should omit the name field of a Location object when creating or updating a location. Please make sure you take out the name field in your PATCH request for updating the specified location to avoid the 400 Bad Request error.

 

We strongly encourage you to use the v3 of the Google My Business API since v2 of the API will only be supported until Oct 5th 2016.

 

Thanks,

Terry

View solution in original post

Re: V3 location.name problem on Updates (Patch)

Visitor ✭ ✭ ✭
# 2
Visitor ✭ ✭ ✭
Hmm, I reverted back to the v2 code and am getting: "Request throttled due to daily limit being reached." so this may be something else.
Marked as Best Answer.
Solution
Accepted by topic author Stephen K
May 2016

Re: V3 location.name problem on Updates (Patch)

Google Employee
# 3
Google Employee

Hi @Stephen K,

 

The name field of a Location object is read-only for the version 3 (v3) of the Google My Business API. You should omit the name field of a Location object when creating or updating a location. Please make sure you take out the name field in your PATCH request for updating the specified location to avoid the 400 Bad Request error.

 

We strongly encourage you to use the v3 of the Google My Business API since v2 of the API will only be supported until Oct 5th 2016.

 

Thanks,

Terry

Re: V3 location.name problem on Updates (Patch)

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭
That totally worked.

Thanks Terry.

Re: V3 location.name problem on Updates (Patch)

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭
I had the same problem, should probably update the v3 samples as I don't think this would work anymore:

public static void updateLocation(String locationName, String name) throws Exception {
Location location = new Location()
.setName(locationName) //can't set this in v3, update will fail
.setLocationName(name);

Re: V3 location.name problem on Updates (Patch)

Google Employee
# 6
Google Employee

Hi @Andrew S,

 

Thank you for pointing this out! We'll take a look at the Java code samples for this issue and try to clarify it in the documentation to reflect the changes of the API.

 

Thanks,

Terry

V3 location.name problem on Updates (Patch)

Visitor ✭ ✭ ✭
# 7
Visitor ✭ ✭ ✭

Hi Andrew,

 

I am getting the error while doing patch, can you please let me know if you have faced the below issue?

 

Exception in thread "main" java.lang.IllegalArgumentException: Parameter name must conform to the pattern ^accounts/[^/]*/locations/[^/]*$
at com.google.api.client.repackaged.com.google.common.base.Preconditions.checkArgument(Preconditions.java:92)
at com.google.api.client.util.Preconditions.checkArgument(Preconditions.java:49)
at com.google.api.services.mybusiness.v3.Mybusiness$Accounts$Locations$Patch.<init>(Mybusiness.java:2620)
at com.google.api.services.mybusiness.v3.Mybusiness$Accounts$Locations.patch(Mybusiness.java:2585)

 

Reply on this is really appreciated

 

V3 location.name problem on Updates (Patch)

[ Edited ]
Visitor ✭ ✭ ✭
# 8
Visitor ✭ ✭ ✭

I think that error is pretty self explanatory, you need to inspect the name parameter and see what you set it to, it needs to be in a format like accounts/12345/location/12345. It is not the name like 'Apple NYC' that would be set on LocationName.