204 No Content
The request worked and there is nothing to send back. The response has no body, and the browser stays on the current page.
What 204 No Content means
APIs often return 204 after a DELETE, or after a PUT or PATCH when the client does not need the updated resource back.
A 204 response cannot contain a body. Calling response.json() on it in JavaScript throws an "Unexpected end of JSON input" error, so check the status before parsing.
Compare with 200 (success with a body) and 205 (success, and reset the form that sent the request).
Example response
HTTP/1.1 204 No ContentHow to check for a 204 response
cURL
# Print only the status code
curl -s -o /dev/null -w "%{http_code}\n" https://example.com/JavaScript (Node.js)
const res = await fetch("https://example.com/");
if (res.status === 204) {
console.log(res.status, res.statusText);
}Python
import requests
res = requests.get("https://example.com/")
if res.status_code == 204:
print(res.status_code, res.reason)Go
res, err := http.Get("https://example.com/")
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
if res.StatusCode == 204 {
fmt.Println(res.Status)
}Specification
204 No Content is defined in RFC 9110, section 15.3.5.
Related status codes
- 200
The request worked. The response body holds the result, such as the page, file or JSON data the client asked for.
- 205
The request worked and the client should reset the document view, such as clearing the form the user just submitted.
- 201
The request worked and created a new resource. The Location header usually points to the URL of the new item.