kaydotai/kay

422 error from browser POST

Closed this issue · 2 comments

Hi, Having some issues using the POST to retrieve endpoint, hope I'm just doing something silly.

curl 'https://api.kay.ai/retrieve' \
  -H 'authority: api.kay.ai' \
  -H 'accept: */*' \
  -H 'accept-language: en-GB,en;q=0.9,en-US;q=0.8' \
  -H 'api-key: REMOVED_KEY_FOR _GH_ISSUE' \
  -H 'content-type: text/plain;charset=UTF-8' \
  -H 'cookie: _ga=GA1.1.1476348334.1697181115; _ga_ZC1H9PMR1V=GS1.1.1697281342.2.0.1697281352.0.0.0' \
  -H 'origin: chrome-extension://andkinbbhmhpnagggifmegnbebkffmah' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: none' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36 Edg/117.0.2045.55' \
  --data-raw '{"query":"AstraZeneca gross profit for the past 3 quarters","dataset_config":{"dataset_id":"company","data_types":["10-K","10-Q","8-K"]},"retrieval_config":{"instruction":"Do best retrieval","num_context":3}}' \
  --compressed

Returns:

[{'type': 'model_attributes_type', 'loc': ('body',), 'msg': 'Input should be a valid dictionary or object to extract fields from', 'input': b'{"query":"AstraZeneca gross profit for the past 3 quarters","dataset_config":{"dataset_id":"company","data_types":["10-K","10-Q","8-K"]},"retrieval_config":{"instruction":"Do best retrieval","num_context":3}}', 'url': 'https://api.kay.ai/docs#/default/retrieve_retrieve_post'}]

Any help much appreciated.

plv commented

Hey @chrisj74 , sorry for the late response! Your --data-raw is well-formed, but it appears that you have your content-type header set to text/plain instead of application/json. Using application/json should fix your issue.

I've also filed a ticket to make the response message better in this scenario. If you have any more questions feel free to email us: hello [AT] kay.ai

Hi @plv thanks for the spot. All resolved.