googleapis / google-api-php-client

A PHP client library for accessing Google APIs
Apache License 2.0
9.2k stars 3.52k forks source link

Not able to get Google Business Location Attribute Details #2540

Open snehupadhyay2012 opened 6 months ago

snehupadhyay2012 commented 6 months ago

Hello Team, We are using google/apiclient( v2.15.1 ), And i want to get the location attributes so i am using Resource Location and calling the getAttributes function as per documentation. But i am getting below error.

{ "error": { "code": 400, "message": "Request contains an invalid argument.", "errors": [ { "message": "Request contains an invalid argument.", "domain": "global", "reason": "badRequest" } ], "status": "INVALID_ARGUMENT", "details": [ { "@type": "type.googleapis.com/google.rpc.BadRequest", "fieldViolations": [ { "field": "read_mask", "description": "Field is required" } ] } ] } }

But even if i pass read_mask optional param i am getting error.

unknown parameter: 'readMask'

But when i am calling HTTP API : https://mybusinessbusinessinformation.googleapis.com/v1/locations/5544303602100449194/attributes i am getting the response. Please look into this issue.

saranshdhingra commented 6 months ago

Hi @snehupadhyay2012 Could you please share the code that you are using?

Thanks.

snehupadhyay2012 commented 6 months ago

Hi @saranshdhingra

<?php 
include_once __DIR__ . '/../util.php';

$my_business_info = new Google_Service_MyBusinessBusinessInformation($client);
$storeAttrInfo = $my_business_info->locations->getAttributes($_GET['store_id']);

When i run this above code i am getting below fatal error.

Fatal error: Uncaught Google\Service\Exception: { "error": { "code": 400, "message": "Request contains an invalid argument.", "errors": [ { "message": "Request contains an invalid argument.", "domain": "global", "reason": "badRequest" } ], "status": "INVALID_ARGUMENT", "details": [ { "@type": "type.googleapis.com/google.rpc.BadRequest", "fieldViolations": [ { "field": "read_mask", "description": "Field is required" } ] } ] } } in /var/www/html/node_web_services/vendor/google/apiclient/src/Http/REST.php:134 Stack trace: #0 /var/www/html/node_web_services/vendor/google/apiclient/src/Http/REST.php(107): Google\Http\REST::decodeHttpResponse() #1 [internal function]: Google\Http\REST::doExecute() #2 /var/www/html/node_web_services/vendor/google/apiclient/src/Task/Runner.php(187): call_user_func_array() #3 /var/www/html/node_web_services/vendor/google/apiclient/src/Http/REST.php(66): Google\Task\Runner->run() #4 /var/www/html/node_web_services/vendor/google/apiclient/src/Client.php(926): Google\Http\REST::execute() #5 /var/www/html/node_web_services/vendor/google/apiclient/src/Service/Resource.php(238): Google\Client->execute() #6 /var/www/html/node_web_services/vendor/google/apiclient-services/src/MyBusinessBusinessInformation/Resource/Locations.php(80): Google\Service\Resource->call() #7 /var/www/html/node_web_services/store/edit.php(8): Google\Service\MyBusinessBusinessInformation\Resource\Locations->getAttributes() #8 {main} thrown in /var/www/html/node_web_services/vendor/google/apiclient/src/Http/REST.php on line 134

And when i am passing read_mask field like i was doing while fetching store.

<?php 
include_once __DIR__ . '/../util.php';

$my_business_info = new Google_Service_MyBusinessBusinessInformation($client);
$storeAttrInfo = $my_business_info->locations->getAttributes($_GET['store_id'],["readMask"=>[]]);

It is again throwing below error. Fatal error: Uncaught Google\Exception: (getAttributes) unknown parameter: 'readMask' in /var/www/html/node_web_services/vendor/google/apiclient/src/Service/Resource.php:155 Stack trace: #0 /var/www/html/node_web_services/vendor/google/apiclient-services/src/MyBusinessBusinessInformation/Resource/Locations.php(80): Google\Service\Resource->call() #1 /var/www/html/node_web_services/store/edit.php(7): Google\Service\MyBusinessBusinessInformation\Resource\Locations->getAttributes() #2 {main} thrown in /var/www/html/node_web_services/vendor/google/apiclient/src/Service/Resource.php on line 155

shivgautam commented 2 months ago

@saranshdhingra - Any update on this?