【发布时间】:2016-04-06 12:34:41
【问题描述】:
一段时间以来,我一直在尝试建立一个有效的 PATCH 请求以通过 Googles My Business API 更新位置,但我还没有成功提出请求。
这是我最后一次尝试请求的样子:
{
location": {
"primaryPhone": "1-800-TEST"
},
"languageCode": "en",
"fieldMask": "primaryPhone",
"validateOnly": true
}
当我省略 fieldMask 之类的内容时,我收到一条错误消息,指出未设置 address.country,但它存在时我收到以下错误:
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT"
}
}
信息量不大:P
有什么想法我可能做错了吗?有人有工作样品要求吗? (最好是更新营业时间的):)
【问题讨论】:
-
看不到您的代码有点难以帮助,但是。尝试做一个locations.get,它将返回一个位置主体,对它进行更改并将其修补回来。我认为您需要设置所有无法选择的字段。
-
据我了解 (developers.google.com/my-business/reference/rest/v2/…) 如果我使用
fieldMask属性指定哪些字段,我应该只能提交需要更新的字段:The specific fields to update. If no mask is specified, then this is treated as a full update and all fields are set to the values passed in, which may include unsetting empty fields in the request.A comma-separated list of fully qualified names of fields. Example: "user.displayName,photo".跨度> -
代码也不是很有趣,例如
GET请求工作正常 - 我几乎可以肯定请求的正文有问题,但我没有能够弄清楚还有什么:) -
这就是我从来没有通过只发送几个字段但发送一切正常的理论让它工作。
-
那么这可能是个问题,它不是 HTTP Get 请求,而是 HTTP Patch 请求。
标签: google-api patch google-my-business-api