googleapis / googleapis/google-api-php-client-services

Cannot get list of questions using \Google\Service\MyBusinessQA::locations_questions->listLocationsQuestions();

Open
#6,496 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
1.3k
Forks
320
Avg merge
2h 32m
Merged PRs (30d)
193

Description

#### Environment details

- OS: AlmaLinux 9.5
- PHP version: 8.3
- Package name and version: v0.396.0 \Google\Service\MyBusinessQA

#### Steps to reproduce

1. Make a call to locations_questions->listLocationsQuestions($name);
2. Get error no matter how you do it
3. Make call with a plain curl request and get the actual results

#### Code example

```php
// 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

```json
{
"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

```php
// 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'

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.