Empty body in GET request throws error

I’m using a third party app that sends requests with an empty body (e.g. {}) When a GET request is sent to /v1/threads/{{thread_id}}/messages it returns the following error:

{
    "error": {
        "message": "Invalid request to GET /v1/threads/{{thread_id}}/messages. You provided a body with this GET request. Either submit a POST request, or pass your arguments in the query string.",
        "type": "invalid_request_error",
        "param": null,
        "code": null
    }
}

Many other APIs won’t error out if the body is empty and some even allow for data in the body of a GET request and will still return the response data.

Is there any way around this? I can’t easily change the app to not send a blank body. And a body isn’t really being sent. Any suggestions would be helpful.

The response an API gives to a payload with an empty body depends on the design of the API.

If OpenAI’s API returns an error for a payload with an empty body, that behavior is part of the API’s specifications and cannot be changed.

I don’t know what the third-party app is doing, but if the third-party app cannot be modified to avoid sending a payload with an empty body, and if OpenAI’s API is designed to return an error for such a request, there is no workaround for this issue.

Prior to sending, check if the message is empty, and if it is, then you don’t send it. That would be the ideal solution for this.

3 Likes