-
Notifications
You must be signed in to change notification settings - Fork 315
Open
Description
Environment details
- OS: AlmaLinux 9.5
- PHP version: 8.3
- Package name and version: v0.396.0 \Google\Service\MyBusinessQA
Steps to reproduce
- Make a call to locations_questions->listLocationsQuestions($name);
- Get error no matter how you do it
- Make call with a plain curl request and get the actual results
Code example
// SET UP GOOGLE CLIENT
$this->googleClient = new \Google\Client();
$this->googleClient->setApplicationName("GMB API");
$this->googleClient->setAuthConfig('client_secrets.json');
$this->googleClient->refreshToken($secretToken);
$token = $this->googleClient->getAccessToken();
$this->googleClient->setAccessToken($token);
$this->gmbQAService = new \Google\Service\MyBusinessQA($this->googleClient);
// SET LOCATION
$name = "locations/$gmbLocation";
// GET QUESTIONS
try {
$getQA = $this->gmbQAService->locations_questions->listLocationsQuestions($name);
} catch (\Exception $e) {
echo $e->getMessage();
}
// QUESTIONS DATA
echo json_encode($getQA);This code produces the following output
{
"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"
}
]
}
]
}
}If you add in the "readMask" with the following code
// SET UP GOOGLE CLIENT
$this->googleClient = new \Google\Client();
$this->googleClient->setApplicationName("GMB API");
$this->googleClient->setAuthConfig('client_secrets.json');
$this->googleClient->refreshToken($secretToken);
$token = $this->googleClient->getAccessToken();
$this->googleClient->setAccessToken($token);
$this->gmbQAService = new \Google\Service\MyBusinessQA($this->googleClient);
// SET LOCATION
$name = "locations/$gmbLocation";
// GET QUESTIONS
$optParams = [
"readMask" => ['questions']
];
try {
$getQA = $this->gmbQAService->locations_questions->listLocationsQuestions($name, $optParams);
} catch (\Exception $e) {
echo $e->getMessage();
}
// QUESTIONS DATA
echo json_encode($getQA);You get the following output in the Exception
(list) unknown parameter: 'readMask'
Metadata
Metadata
Assignees
Labels
No labels