Google 我的公司 API 更新主要类别时出错

Google My Business API error on updating the primary category

使用 Google 我的商家 API 更新主要类别时,显示此错误:

+"error": {#278 ▼
    +"code": 400
    +"message": "Request contains an invalid argument."
    +"status": "INVALID_ARGUMENT"
    +"details": array:1 [▼
      0 => {#269 ▼
        +"@type": "type.googleapis.com/google.rpc.BadRequest"
        +"fieldViolations": array:1 [▼
          0 => {#275 ▼
            +"field": "update_mask"
            +"description": "primary or additional categories cannot be updated independently."
          }
        ]
      }
    ]
}

这是我的 PHP 代码:

<?php

$locationData = array();
$locationData['title'] = $data['title'];
$locationData['categories']['primaryCategory']['name'] = 'gcid:website_designer';

$updateMask = array(
    'title', 
    'categories.primaryCategory.name'
);

$queryParams = array(
    'updateMask' => implode(',', $updateMask)
);

// Prepare new cURL resource
$curl = curl_init('https://mybusinessbusinessinformation.googleapis.com/v1/locations/'.$locationId.'/?'.http_build_query($queryParams));
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PATCH');
curl_setopt($curl, CURLOPT_POSTFIELDS, $locationData);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Authorization: Bearer ' . $accessToken,
));

// Submit the DELETE request
$response = curl_exec($curl);

// Close cURL session handle
curl_close($curl);

$location = json_decode($response);

echo "<pre>";
print_r($location);
echo "</pre>";

这个错误是什么意思?

primary or additional categories cannot be updated independently.

当我取下这个面具时它成功更新了公司名称

categories.primaryCategory.name

所以,我很困惑应该添加什么掩码来更新主要类别,或者是否有一个单独的 API?

我基于此文档:

https://developers.google.com/my-business/reference/businessinformation/rest/v1/locations/patch

在您的更新掩码中,您只需指定 categories 并提供两者。 phoneNumbers

也一样