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

Patch the location OpenInfo

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

I want to set the OpenInfo and I get this error:

Google_Exception
{
  "error": {
    "code": 400,
    "message": "Invalid JSON payload received. Unknown name \"status\" at 'location.open_info.status': Proto field is not repeating, cannot start list.",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.BadRequest",
        "fieldViolations": [
          {
            "field": "location.open_info.status",
            "description": "Invalid JSON payload received. Unknown name \"status\" at 'location.open_info.status': Proto field is not repeating, cannot start list."
          }
        ]
      }
    ]
  }
}

  

 I instantiate a new Google_Service_Mybusiness_OpenInfo object and I use setStatus()
method to add "OPEN", Then I append this to My location object using setOpenInfo() method.

Please give me a clue,

Thank you!

1 Expert replyverified_user

Re: Patch the location OpenInfo

Google Employee
# 2
Google Employee

Hi @Andrei C,

 

The following is the full HTTP request message of a PATCH request including the URI, query parameters, and the JSON payloads of request body for marking a location as “OPEN” by setting the OpenInfo object with the according status via the API:

 

https://mybusiness.googleapis.com/v3/accounts/account_name/locations/locationId?languageCode=en&fieldMask=openInfo&validateOnly=false

{
 "openInfo": {
   "status": "OPEN"
 },
}

 

Judging from the source code you provided,  I suppose you are using the PHP client library with v1-branch of the Google API Client Library for PHP. The following is a code snippet for marking a location as “CLOSED_PERMANENTLY” by setting the OpenInfo object with the according status via the API with the PHP client library:

 $name = $location->name;

 $location->name = NULL;

 $location = new Google_Service_Mybusiness_Location();

 

 $openInfo = new Google_Service_Mybusiness_OpenInfo();

 $openInfo->status = "CLOSED_PERMANENTLY";

 $location->setOpenInfo($openInfo);

 

 try {

   $updatedlocation = $locations->patch($name, $location, array('languageCode' => 'en', 'fieldMask' => 'openInfo', 'validateOnly' => FALSE));

 } catch (Exception $e) {

   print "Caught exception: " . $e->getMessage() . "\n";

 }

 

Thanks,

Terry