Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

[Urgent] Unsupported Content Type application/json; charset=UTF-8 #465

Open
benedictstrube opened this issue Feb 13, 2024 · 3 comments · May be fixed by #466
Open

[Urgent] Unsupported Content Type application/json; charset=UTF-8 #465

benedictstrube opened this issue Feb 13, 2024 · 3 comments · May be fixed by #466

Comments

@benedictstrube
Copy link

I am getting this error when attempting to execute createThread on an OpenAiService instance.

Unsupported content type: 'application/json; charset=UTF-8'. This API method only accepts 'application/json' requests, but you specified the header 'Content-Type: application/json; charset=UTF-8'. Please try again with a supported content type.

Seems like OpenAI changed something internally. Not tested on other requests yet, but if my assumption is correct, that seems quite urgent. As of now, all our requests to OpenAI are failing.

@benedictstrube benedictstrube linked a pull request Feb 13, 2024 that will close this issue
@benedictstrube
Copy link
Author

benedictstrube commented Feb 13, 2024

Attached a PR to fix this for the Assistants API, as those are the requests, that are failing right now without setting the Content-Type explicitly to application/json. However, having a look at the documentation, it seems like setting the Content-Type for all requests is the correct way:

curl https://api.openai.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
     "model": "gpt-3.5-turbo",
     "messages": [{"role": "user", "content": "Say this is a test!"}],
     "temperature": 0.7
   }'

(example request from their documentation)

@propertius
Copy link

Hi @benedictstrube. I was having the same issue but out of nowhere it seems to be working again.

@benedictstrube
Copy link
Author

Thanks @propertius for the heads up! I already posted a PR that sets the Content Type explicitly according to specification. I think it still might be a good idea to merge this, as this might happen again anytime in the future, if OpenAI decides to be restrictive regarding that. 😄

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants