200 OK
Fault: Neither
TL;DR
The request was successfully received, understood, and accepted.
The request has succeeded.
What This Error Means
The request has succeeded.
The request was successfully received, understood, and accepted.
Common Causes
- Successful GET request
- Successful POST that doesn't create a resource
- Any successful request
How to Fix It (For Visitors)
- No action needed - request successful
How to Fix It (For Developers/Admins)
- Return 200 for successful operations
- Include response body with requested data
Code Examples
Here's how to return a 200 status code in various programming languages:
Python (Flask)
from flask import Flask, jsonify
app = Flask(__name__)
@app.route('/endpoint')
def endpoint():
return jsonify({"message": "OK"}), 200
Node.js (Express)
const express = require('express');
const app = express();
app.get('/endpoint', (req, res) => {
res.status(200).json({ message: 'OK' });
});
PHP
<?php
http_response_code(200);
header('Content-Type: application/json');
echo json_encode(['message' => 'OK']);
?>
Go
package main
import (
"encoding/json"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
json.NewEncoder(w).Encode(map[string]string{
"message": "OK",
})
}
Java (Spring Boot)
@GetMapping("/endpoint")
public ResponseEntity<Map<String, String>> endpoint() {
Map<String, String> response = new HashMap<>();
response.put("message", "OK");
return ResponseEntity.status(200).body(response);
}
Ruby (Sinatra)
get '/endpoint' do
status 200
json message: 'OK'
end
Browser Compatibility
| Browser | Support | Notes |
|---|---|---|
| Chrome | ✓ Full Support | All versions |
| Firefox | ✓ Full Support | All versions |
| Safari | ✓ Full Support | All versions |
| Edge | ✓ Full Support | All versions |
Official Specification
This status code is defined in RFC 7231 Section 6.3.1.