Code Examples
Here are examples of how to test HTTP 204 responses in different programming languages:
Select options below to see how to use advanced features in your code:
curl https://free.mockerapi.com/204
{
"success": true,
"status": 204,
"statusText": "No Content - The request succeeded but there is no content to return",
"timestamp": "2025-10-08T10:30:45.123Z",
"request": {
"method": "GET",
"url": "/204",
"fullUrl": "https://free.mockerapi.com/204"
}
}fetch('https://free.mockerapi.com/204')
.then(response => {
console.log('Status:', response.status); // 204
return response.json();
})
.then(data => {
console.log('Success:', data);
})
.catch(error => {
console.error('Error:', error);
});{
"success": true,
"status": 204,
"statusText": "No Content - The request succeeded but there is no content to return",
"timestamp": "2025-10-08T10:30:45.123Z",
"request": {
"method": "GET",
"url": "/204",
"fullUrl": "https://free.mockerapi.com/204"
}
}import requests
response = requests.get('https://free.mockerapi.com/204')
print(f'Status Code: {response.status_code}') # 204
print(f'Response: {response.json()}'){
"success": true,
"status": 204,
"statusText": "No Content - The request succeeded but there is no content to return",
"timestamp": "2025-10-08T10:30:45.123Z",
"request": {
"method": "GET",
"url": "/204",
"fullUrl": "https://free.mockerapi.com/204"
}
}{
"success": true,
"status": 204,
"statusText": "No Content - The request succeeded but there is no content to return",
"timestamp": "2025-10-08T10:30:45.123Z",
"request": {
"method": "GET",
"url": "/204",
"fullUrl": "https://free.mockerapi.com/204"
}
}require 'net/http'
require 'json'
uri = URI('https://free.mockerapi.com/204')
response = Net::HTTP.get_response(uri)
puts "Status Code: #{response.code}" # 204
puts "Response: #{JSON.parse(response.body)}"{
"success": true,
"status": 204,
"statusText": "No Content - The request succeeded but there is no content to return",
"timestamp": "2025-10-08T10:30:45.123Z",
"request": {
"method": "GET",
"url": "/204",
"fullUrl": "https://free.mockerapi.com/204"
}
}package main
import (
"fmt"
"io"
"net/http"
)
func main() {
resp, err := http.Get("https://free.mockerapi.com/204")
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Printf("Status Code: %d\n", resp.StatusCode) // 204
body, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Printf("Response: %s\n", body)
}{
"success": true,
"status": 204,
"statusText": "No Content - The request succeeded but there is no content to return",
"timestamp": "2025-10-08T10:30:45.123Z",
"request": {
"method": "GET",
"url": "/204",
"fullUrl": "https://free.mockerapi.com/204"
}
}import java.net.http.*;
import java.net.URI;
public class HttpStatusTest {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://free.mockerapi.com/204"))
.GET()
.build();
HttpResponse response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println("Status Code: " + response.statusCode()); // 204
System.out.println("Response: " + response.body());
}
} {
"success": true,
"status": 204,
"statusText": "No Content - The request succeeded but there is no content to return",
"timestamp": "2025-10-08T10:30:45.123Z",
"request": {
"method": "GET",
"url": "/204",
"fullUrl": "https://free.mockerapi.com/204"
}
}const https = require('https');
https.get('https://free.mockerapi.com/204', (res) => {
console.log('Status Code:', res.statusCode); // 204
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
console.log('Response:', JSON.parse(data));
});
}).on('error', (err) => {
console.error('Error:', err.message);
});{
"success": true,
"status": 204,
"statusText": "No Content - The request succeeded but there is no content to return",
"timestamp": "2025-10-08T10:30:45.123Z",
"request": {
"method": "GET",
"url": "/204",
"fullUrl": "https://free.mockerapi.com/204"
}
}What is HTTP 204 No Content?
HTTP 204 No Content indicates that the server successfully processed the request, but is not returning any content. The response may include headers but has no message body. This is commonly used for actions that don't require a response body.
- No Response Body: The server doesn't send any content in the response
- Successful Operation: The request was processed successfully
- DELETE Requests: Commonly used for successful DELETE operations
- Headers Only: May include response headers without body content
When Does This Happen?
A 204 No Content response is returned when the server successfully processes a request but doesn't need to return any content. You'll see this status code when:
- Successfully deleting a resource (DELETE requests)
- Successfully updating a resource without returning the updated data
- Saving user preferences or settings
- Acknowledging actions that don't require a response
- Handling form submissions that don't need confirmation data
Try It Live
Click the button below to make a live request and see the 204 No Content response
Common Use Cases
🗑️ DELETE Operations
Test deletion operations that return no content upon success.
💾 Silent Updates
Mock update operations that don't need to return the updated resource.
⚙️ Settings & Preferences
Simulate saving configuration changes without response bodies.
✓ Acknowledgments
Test scenarios where the server just acknowledges an action.
🔄 Polling Endpoints
Mock polling endpoints that return 204 when no new data is available.
📝 Form Submissions
Handle form submissions that don't require confirmation data in response.