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

Patch issue with location objects

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

The issue that I am having is when I try and send a batch that has a object in it (aka Google_Service_Mybusiness_Address) i get  400,  "Request contains an invalid argument. But if I just update a basic variable like websiteURL it goes no problem. below are the working and not working codes

 

 not working

$location = new Google_Service_Mybusiness_Location(); $testaddress = array("testline1","testline2"); $newAddress = new Google_Service_Mybusiness_Address(); $newAddress->setAddressLines($testaddress); $newAddress->setLocality("test"); $newAddress->setAdministrativeArea("test"); $newAddress->setCountry("US"); $newAddress->setPostalCode("test"); $newAddress->setSubLocality("test"); $location->setAddress($newAddress); try { $updatedlocation = $mybusinessService->accounts_locations->patch($name, $location, array( "languageCode"=>"en",'validateOnly' => true,"fieldMask"=>"address" )); echo "done"; } catch (Exception $e) { print "Caught exception: " . $e->getMessage() . "\n"; }

working

$location = new Google_Service_Mybusiness_Location(); $location->setWebsiteUrl("http://www.blimpie.com/"); try { $updatedlocation = $mybusinessService->accounts_locations->patch($name, $location, array( "languageCode"=>"en",'validateOnly' => true,"fieldMask"=>"address" )); echo "done"; } catch (Exception $e) { print "Caught exception: " . $e->getMessage() . "\n"; }

1 Expert replyverified_user

Patch issue with location objects

N/A
# 2
N/A

I am still looking for assistance on this issue

Re: Patch issue with location objects

Google Employee
# 3
Google Employee

Hi @Ryan P,

 

Judging from the source code you provided, we suggest you use the actual values instead of test values while sending a PATCH request, and make sure your address is accurate and precise as per the guidelines for representing your business on Google.

 

In addition, since the PHP client library doesn’t currently support the display of detailed error messages, we suggest you follow the Make a simple HTTP request step-by-step guide on the Google Developers site to learn how to use the OAuth 2.0 Playground for troubleshooting errors with detailed error messages when sending requests with data via the Google My Business API.

 

Thanks,

The Google My Business API team

Patch issue with location objects

N/A
# 4
N/A

I was using values and went to the test values that are in there for this post.


Using the HTTP is not going to help in my instance because I am having problems with the PHP. I can send a patch through for "WebsiteUrl" using the code that I sent you, the issue is anytime I send information for an object through I get the error I explained.

Is the way the object is being built and passed from address object to the location object?

Making a simple HTTP request is not going to solve my issue or help figure out why it will not take the object that I am building because as you know they are both built differently.

Can someone look at my code and let me know why I am getting the error that I posted.

Re: Patch issue with location objects

[ Edited ]
Google Employee
# 5
Google Employee

Hi @Ryan P

 

As we previously mentioned, according to our Guidelines for representing your business on Google, you should use a precise, accurate address to describe your business location and not dummy data when sending requests via the API.

 

Please note that you may receive the 400 Bad Request error due to an invalid JSON payload when sending a PATCH request to update the specified location with the PHP client library. A workaround for this issue is to always create a new Location object for a location update.

 

In addition, it's best practice to always use a fieldMask for updating specific fields so that your other location data are preserved.

 

Thanks,

The Google My Business API team