Google People API:收到无效的 JSON 有效负载(邮递员)

发布于 2025-01-11 20:16:57 字数 1354 浏览 2 评论 0原文

在 postman 中工作并尝试测试 Google People API,并遇到以下错误。

>   "error": {
>     "code": 400,
>     "message": "Invalid JSON payload received. Unknown name \"personFields\": Cannot bind query parameter. Field 'personFields'
> could not be found in request message.",
>     "status": "INVALID_ARGUMENT",
>     "details": [
>       {
>         "@type": "type.googleapis.com/google.rpc.BadRequest",
>         "fieldViolations": [
>           {
>             "description": "Invalid JSON payload received. Unknown name \"personFields\": Cannot bind query parameter. Field
> 'personFields' could not be found in request message."
>           }
>         ]
>       }
>     ]   } }

这是我尝试运行的 GET 请求:

https://people.googleapis.com/v1/people:[email protected]&personFields=person.email_addresses

我已阅读 google People 文档,但不太明白我做错了什么。在文档中它提到我需要一个 personFields 查询参数,但它抛出了上面的错误。我认为我的格式在某种意义上是错误的,但我在网上找不到大量具体的例子。

有关更多上下文,我尝试搜索用户的通讯录并尝试查找电子邮件地址并返回相关信息。任何帮助将不胜感激。

Working and trying to test the Google People API in postman, and running into the following error.

>   "error": {
>     "code": 400,
>     "message": "Invalid JSON payload received. Unknown name \"personFields\": Cannot bind query parameter. Field 'personFields'
> could not be found in request message.",
>     "status": "INVALID_ARGUMENT",
>     "details": [
>       {
>         "@type": "type.googleapis.com/google.rpc.BadRequest",
>         "fieldViolations": [
>           {
>             "description": "Invalid JSON payload received. Unknown name \"personFields\": Cannot bind query parameter. Field
> 'personFields' could not be found in request message."
>           }
>         ]
>       }
>     ]   } }

Here is the GET request I am trying to run:

https://people.googleapis.com/v1/people:[email protected]&personFields=person.email_addresses

I have read through the google People Docs but do not quite understand what I am doing wrong. In the docs it mentions I need a personFields query param, yet it is throwing the error above. I assume my formatting is wrong in some sense, but there aren't a ton of concrete examples I could find online.

For more context, I am attempting to search through the user's contact book and try and find the email address, and return pertinent information. Any help would be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

愿与i 2025-01-18 20:16:57

如果您想要搜索其他用户的通讯录,则需要使用以下端点:

获取 https://people.googleapis.com/v1 /{resourceName=people/*}/connections

作为 记录在此处这是用于实现您需要的内容的:

“...提供经过身份验证的用户的联系人列表...”

使用上面的内容,这是您在 Postman 中需要的 URL:

https://people.googleapis.com /v1/people/me/connections?pageSize=300&personFields=emailAddresses

其中:

Me = 经过身份验证的用户。

PageSize = 可以是 1 到 1000 之间的任意数字

需要注意的是:

  1. 如果您想添加其他 personFields 属性,可以通过用逗号分隔它们来实现。 例如:personFields=emailAddresses,phoneNumbers
  2. 您没有提及您要检查的另一个帐户是免费 Gmail.com 帐户还是 Google Workspace 帐户。
  3. 如果你的情况是后者。您需要模拟该用户才能访问该用户的联系人列表。我在我的终端上进行了测试,但我不太确定如何在 Postman 上执行此操作。如果未进行模拟,您将只能使用:“me”作为所需的resourceName 参数。

If what you are looking to do is search through another user's contact book instead you need to use the endpoint below:

GET https://people.googleapis.com/v1/{resourceName=people/*}/connections

As documented here this is the one to be used to achieve what you need:

"... Provides a list of the authenticated user's contacts ..."

Using the above this is the URL you will need in Postman:

https://people.googleapis.com/v1/people/me/connections?pageSize=300&personFields=emailAddresses

Where:

Me = the authenticated user.

PageSize = can be any number from 1 to 1000

Something to note:

  1. If you would like to add other personFields attributes, you can do so by separating them with commas. Like: personFields=emailAddresses,phoneNumbers
  2. You did not mention whether the other account you want to check is a free Gmail.com account or a Google Workspace one.
  3. If the latter is your case. you will need to impersonate the user to be able to access the user's contact list. I tested on my end, but I am not really sure how to go about doing that on Postman. If impersonation is not done you will only be able to use: "me" as the required resourceName parameter.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文