Error "Missing required parameter: 'role'" when sending a message to a thread via OpenAI API

Hi! I’m encountering an issue when trying to send a message to a thread using the OpenAI API. I’m using the following URL for my POST request:

…/v1/threads/thread_Nz3FCZlsQxb11zcOzB38UQcf/messages

{
  "messages": [
    {
      "role": "user",
      "content": "How does AI work?"
    }
  ]
}

However, I keep getting a 400 Bad Request error with the following message: ```
“Missing required parameter: ‘role’”
I’ve double-checked that the role parameter is correctly set to "user", and the content field is properly formatted. I also ensured that the headers, including Authorization and Content-Type, are set correctly. I’ve tried simplifying the request and removing unnecessary characters, but the error persists.
Question:
Are there any specific details or requirements I might be missing when sending messages to a thread via the OpenAI API? Could there be any new constraints or mandatory parameters that I overlooked?

You should only be passing role and content in the body.

Wrong :x:

{
  "messages": [
    {
      "role": "user",
      "content": "How does AI work?"
    }
  ]
}

Correct :white_check_mark:

{
      "role": "user",
      "content": "How does AI work?"
    }
2 Likes

Hi. Thanks for the tip. Could you also help me figure out how to get a response from the assistant to a specific query?

Hey lets connect over my mail. So that i can guide you properly.