HTTP
Giả lập phản hồi 409 Conflict
The request conflicts with the current state of the server. Often due to concurrent modification or business rule violations.
Xem tài liệu tham khảo đầy đủ →1 Phản hồi HTTP
HTTP/1.1 409 Conflict
Content-Type: application/json
Date: Tue, 25 Feb 2026 12:00:00 GMT
Content-Length: 59
{
"error": "conflict",
"message": "Resource already exists"
}
2 Kiểm tra với curl
curl -i https://httpbin.org/status/409
3 Trả về 409 Conflict trong Framework của bạn
django
from django.http import JsonResponse
def my_view(request):
return JsonResponse(
{"error": "conflict", "message": "Resource already exists"},
status=409,
)
flask
from flask import Flask, jsonify
app = Flask(__name__)
@app.route("/endpoint")
def my_endpoint():
return jsonify({"error": "conflict", "message": "Resource already exists"}), 409
fastapi
from fastapi import FastAPI
from fastapi.responses import JSONResponse
app = FastAPI()
@app.get("/endpoint")
def my_endpoint():
return JSONResponse(
content={"error": "conflict", "message": "Resource already exists"},
status_code=409,
)
express.js
// Express.js
app.get('/endpoint', (req, res) => {
res.status(409).json({"error": "conflict", "message": "Resource already exists"});
});
spring boot
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@RestController
public class MyController {
@GetMapping("/endpoint")
public ResponseEntity<Map<String, Object>> myEndpoint() {
return ResponseEntity
.status(409)
.body(Map.of("error", "conflict",
"message", "Conflict"));
}
}
go net/http
package main
import (
"encoding/json"
"net/http"
)
func myHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(409)
json.NewEncoder(w).Encode(map[string]string{
"error": "conflict",
"message": "Conflict",
})
}
ruby on rails
class MyController < ApplicationController
def my_action
render json: {"error": "conflict", "message": "Resource already exists"},
status: :conflict
end
end
asp.net core
// ASP.NET Core Minimal API
app.MapGet("/endpoint", () =>
Results.Json(
new { error = "conflict", message = "Conflict" },
statusCode: 409
)
);