Curl Returns 200 But Wrong Data: Validate API Responses
Your curl command returns HTTP 200, but the response body contains an error or wrong data. Learn how to detect and handle this.
The Problem: HTTP 200 with Wrong Content
Many APIs return HTTP 200 even when there's an error, putting the error in the response body:
- JSON APIs return 200 with error object
- REST APIs return 200 with HTML error page
- GraphQL returns 200 with errors array
- Health checks return 200 when service is degraded
Checking only HTTP status code isn't enough. You need to validate response body content.
Solution: Validate Response Body
Always check response content, not just HTTP status. Parse JSON responses and look for error fields, or search for error keywords in text responses.
Bash Example: Check JSON Response
#!/bin/bashRESPONSE=$(curl -s -w "\n%{http_code}" "https://api.example.com/data")HTTP_CODE=$(echo "$RESPONSE" | tail -n1)BODY=$(echo "$RESPONSE" | sed '$d')# Extract response validation dataHAS_ERROR=0if echo "$BODY" | grep -q '"error"'; then HAS_ERROR=1fi# Single ping with response data in payload# In DeadManPing panel: set validation rules:# - "status_code" == 200# - "has_error" == 0# Panel will automatically detect violations and alertcurl -X POST "https://deadmanping.com/api/ping/api-check?status_code=$HTTP_CODE&has_error=$HAS_ERROR"Python Example: Validate JSON
import requestsimport jsonresponse = requests.get("https://api.example.com/data")# Extract response data for payloadhas_error = Falsetry: data = response.json() has_error = "error" in dataexcept json.JSONDecodeError: has_error = True # Invalid JSON# Single ping with response data in payload# In DeadManPing panel: set validation rules:# - "status_code" == 200# - "has_error" == False# Panel will automatically detect violations and alertrequests.post(f"https://deadmanping.com/api/ping/api-check?status_code={response.status_code}&has_error={has_error}")Monitoring Response Validation
After adding response validation to your scripts, use a dead man switch to monitor whether validation completed successfully. If your script detects wrong data and exits with error code, the ping never arrives, and you get an alert.
Working Examples
See complete, working code examples in our GitHub repository:
View Examples on GitHub →Start Validating API Responses
DeadManPing monitors whether your response validation completes. Set up monitoring in 2 minutes, get alerts when APIs return wrong data.
Start Monitoring FreeRelated Articles
Learn more about cron job monitoring and troubleshooting:
Curl Success But Wrong Response
How to detect when curl returns success (200) but contains wrong data.
Verify Cron Output
How to verify cron job script output contains expected content.
Verify Script Output Content
How to verify script output contains expected content.
Cron Job Returns Success But Fails
How to detect when cron jobs return success exit code but actually fail.