Discussions
API Bug: content-type ignored on response to 401 Unauthorized
about 2 months ago by null
Low priority/urgency bug:
When I intentionally hit the API without auth, the correct 401 Authorization Required
response is returned - however the response is formatted in HTML, not JSON as specified in the content-type
& Accept
headers.
Steps to reproduce (lines 3 & 4 seem to be ineffective):
curl --request POST \
--url <https://api.perplexity.ai/chat/completions> \
--header "authorization: Bearer ${INTENTIONALLY_BLANK}" \
--header 'Accept: application/json' \
--header 'content-type: application/json' \
--data '{"model": "llama-3-sonar-large-32k-online", "messages": [{"role": "user", "content": "noop"}], "return_citations": true, "stream": false}'
<html>
<head><title>401 Authorization Required</title></head>
<body>
<center><h1>401 Authorization Required</h1></center>
<hr><center>openresty/1.25.3.1</center>
</body>
</html>
Expected Results:
{
"status": 401,
"response": "unauthorized"
}
or similar