Skip to content

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

@machina86

Description

@machina86

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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions