Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
machina86 opened this issue Apr 3, 2025 · 0 comments

Comments

@machina86
Copy link

machina86 commented Apr 3, 2025

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant