(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.
CodePudding user response:
(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.