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

Updating only fields (& not attributes) on Location w/ GMB api v4

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

Hi,

 

I'm attempting to update a Location using v4 of the GMB api but the documentation is ambiguous about how to accomplish a partial update of fields while leaving all attributes intact.

 

The patch page says:

[updateMask]

If no mask is specified, then this is treated as a full update and all fields are set to the values passed in, which may include unsetting empty fields in the request.

 

[attributeMask]

If an attribute is present in the mask and not in the location, it will be removed. An empty mask will update all attributes.

Does "empty" mean (1) an empty string or (2) omitted?

 

The fieldmask reference says:

If a field mask is not present on update, the operation applies to all fields (as if a field mask of all fields has been specified). Note that in the presence of schema evolution, this may mean that fields the client does not know and has therefore not filled into the request will be reset to their default. If this is unwanted behavior, a specific service may require a client to always specify a field mask, producing an error if not.

Since the PATCH operation contains two different fieldmasks, updateMask & attributeMask, it is reasonable to want an update of fields but not attributes. 

 

How can I accomplish this?

 

Thanks,

Casey

1 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author Casey C
March

Re: Updating only fields (& not attributes) on Location w/ GMB api v4

Google Employee
# 4
Google Employee

Hi @Casey C,

 

Yes that’s right. You just need to use the updateMask and omit the attributeMask in your request URI.

PATCH /v4/accounts/<acct>/locations/<loc>?updateMask=<fields>

 

Please let me know if you have any further questions.

 

Thanks,

Shalini

The Google My Business API team

View solution in original post

Re: Updating only fields (& not attributes) on Location w/ GMB api v4

Google Employee
# 2
Google Employee

Hi @Casey C,

 

The updateMask updates the specific fields of the location whereas the attributeMask updates the IDs of the attributes. So if you use the updateMask to update the location endpoints, the attributes will not be affected.

 

Please note, as per the latest addition to the API (v4 version), the parameter attributeMask allows to update the attributes but updated attribute should be available for a location with the given primary category and country.

 

Please let me know if you have any questions!

 

Thanks,

The Google My Business API team

Re: Updating only fields (& not attributes) on Location w/ GMB api v4

[ Edited ]
Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Hi @Shalini S,

 

Thanks for the reply. I understand that the two masks have different usages, that was not my question. Hopefully this explains it a little better --

 

Specifically, I was asking: how can I use the Location PATCH request to update only fields? Do I include only updateMask and simply omit the attributeMask query parameter?

 

The documentation leads me to believe that if I were to omit the attributeMask, as you suggest, it would reset  or "update" all existing attributes.

 

This on Location PATCH:

> An empty mask will update all attributes.

 

This line in the FieldMask reference

> [...] in order to reset all fields of a resource [...] do not provide a mask

 

... hence my request for clarification of the definition of "empty" vs "not provided" vs omitted

 

Scenario 1 - Omit attributeMask | attributeMask not provided:

PATCH /v4/accounts/<acct>/locations/<loc>?updateMask=<fields>

<payload>

 

Scenario 2 - Present (but empty) attributeMask:

PATCH /v4/accounts/<acct>/locations/<loc>?attributeMask=&updateMask=<fields>

<payload>

 

The language of the documentation does not distinguish between the two scenarios above, but I interpret your advice to imply that requests like Scenario 1 will accomplish what I want and Scenario 2 is the situation which would reset all attributes (as the documentation describes).

 

Can you confirm that this is correct?

 

Thanks for the assistance!

Casey

Marked as Best Answer.
Solution
Accepted by topic author Casey C
March

Re: Updating only fields (& not attributes) on Location w/ GMB api v4

Google Employee
# 4
Google Employee

Hi @Casey C,

 

Yes that’s right. You just need to use the updateMask and omit the attributeMask in your request URI.

PATCH /v4/accounts/<acct>/locations/<loc>?updateMask=<fields>

 

Please let me know if you have any further questions.

 

Thanks,

Shalini

The Google My Business API team

Updating only fields (&amp; not attributes) on Location w/ GMB api v4

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭

Hi @Shalini S,

How can I use the Location PATCH request to update only specific attributes?

Do I include only attributeMask and simply omit the updateMask query parameter?

 

Thanks

Re: Updating only fields (&amp; not attributes) on Location w/ GMB api v4

Google Employee
# 6
Google Employee

Hi @Robert S,

 

Yes, you just need to include the attributeMask and omit the updateMask in the request URI.

 

Please note, as per the latest addition to the API (v4 version), the parameter attributeMask allows to update the attributes but updated attribute should be available for a location with the given primary category and country.

 

Thanks,

Shalini

The Google My Business API team