无法在 Zoho People API 上使用 searchParams(HTTP 状态 400)

发布于 2025-01-12 11:34:09 字数 1080 浏览 2 评论 0原文

(与提供 HTTP 状态 400 相关– 错误请求 | Zoho API | searchParams | - 遵循官方文档位于 https://www.zoho.com/people /api/forms-api/search-record.html)

以下内容(导出为curl)获取今天的休假记录时

curl --location -g \
  --request GET "https://people.zoho.eu/people/api/forms/leave/getRecords?searchParams={searchField:'To',searchOperator:'After',searchText:'02-Mar-2022'}|{searchField:'From', searchOperator: 'Before', searchText : '02-Mar-2022'}" \
  --header "Authorization: Zoho-oauthtoken 1000.abcd1234.abcd1234"

当通过 Postman 发送 GET 请求以使用文档提供的 ,我只收到 HTTP 状态400 – Bad Request 错误响应。


但是,在没有 searchParams 的情况下发送相同的请求,获取所有休假记录作为响应,确实有效。因此,在我的例子中,URL 区域和 API 身份验证是正确的。

我按照记录进行了身份验证,并使用我的 clientIdclientSecret 使用 ZOHOPEOPLE.forms.ALL 范围接收了令牌。

(related to Giving HTTP Status 400 – Bad Request | Zoho API | searchParams | - following the official documentation at https://www.zoho.com/people/api/forms-api/search-record.html)

When sending a GET request via Postman to fetch leave-records for today by using the following (exported as curl)

curl --location -g \
  --request GET "https://people.zoho.eu/people/api/forms/leave/getRecords?searchParams={searchField:'To',searchOperator:'After',searchText:'02-Mar-2022'}|{searchField:'From', searchOperator: 'Before', searchText : '02-Mar-2022'}" \
  --header "Authorization: Zoho-oauthtoken 1000.abcd1234.abcd1234"

as provided by the documentation, I receive only a HTTP Status 400 – Bad Request error response.


However, sending the same request without the searchParams, getting all leave records as a response, does work. So the URL region and the Auth to the API are correct in my case.

I authenticated as documented and received the token, using my clientId and clientSecret using the ZOHOPEOPLE.forms.ALL scope.

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

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

发布评论

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

评论(1

书信已泛黄 2025-01-19 11:34:09

(与 给出 HTTP 状态 400 – 错误的答案类似请求 | Zoho API | searchParams |)


文档确实在此处提到了 GET(至少在撰写本文时) - 但该请求实际上适用于 POST 和发送searchParams 作为表单数据。

卷曲示例:

curl --location --request POST 'https://people.zoho.eu/people/api/forms/leave/getRecords' \
--header 'Authorization: Zoho-oauthtoken [...]' \
--form 'searchParams="{searchField: To, searchOperator: After, searchText: 10-Mar-2022}|{searchField: From, searchOperator: Before, searchText: 10-Mar-2022}"'

另请注意,我实际上可以省略 searchParams 中的引号,以提高易读性并减少转义。

(similar answer as for Giving HTTP Status 400 – Bad Request | Zoho API | searchParams |)


The documentation does say GET here (at least at the time of writing) - but the request does actually work with a POST and sending the searchParams as form-data.

curl example:

curl --location --request POST 'https://people.zoho.eu/people/api/forms/leave/getRecords' \
--header 'Authorization: Zoho-oauthtoken [...]' \
--form 'searchParams="{searchField: To, searchOperator: After, searchText: 10-Mar-2022}|{searchField: From, searchOperator: Before, searchText: 10-Mar-2022}"'

Also note that I could actually omit the quotes in the searchParams for better legibility with less escaping.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文