Partial success handling helps your app tell which parts of a request worked and which parts did not. This way, users know exactly what happened without guessing.
Partial success handling in Rest API
HTTP/1.1 207 Multi-Status Content-Type: application/json { "results": [ {"id": 1, "status": "success"}, {"id": 2, "status": "error", "message": "Invalid data"} ] }
The HTTP status code 207 Multi-Status is often used to show partial success.
The response body usually contains details about each item's result.
HTTP/1.1 207 Multi-Status Content-Type: application/json { "results": [ {"file": "image1.png", "status": "uploaded"}, {"file": "image2.png", "status": "failed", "error": "File too large"} ] }
HTTP/1.1 207 Multi-Status Content-Type: application/json { "tasks": [ {"taskId": 101, "status": "completed"}, {"taskId": 102, "status": "failed", "reason": "Timeout"} ] }
This simple Flask app accepts a list of file names. It marks files with names shorter than 10 characters as uploaded, others as failed. It returns a 207 status with details.
from flask import Flask, jsonify, request app = Flask(__name__) @app.route('/upload', methods=['POST']) def upload_files(): files = request.json.get('files', []) results = [] for f in files: if len(f) < 10: results.append({'file': f, 'status': 'uploaded'}) else: results.append({'file': f, 'status': 'failed', 'error': 'File name too long'}) return jsonify({'results': results}), 207 if __name__ == '__main__': app.run(debug=True)
Use HTTP status 207 to clearly indicate partial success.
Always include detailed info in the response body so clients know what succeeded or failed.
Partial success helps avoid confusion and improves user experience.
Partial success handling tells which parts of a request worked and which did not.
Use HTTP 207 Multi-Status with detailed JSON results.
This approach helps users understand exactly what happened.
Practice
HTTP 207 Multi-Status indicate in REST API partial success handling?Solution
Step 1: Understand HTTP 207 Multi-Status meaning
HTTP 207 is used to report multiple status codes for different parts of a single request.Step 2: Relate to partial success handling
This status code indicates that some parts succeeded and others failed, providing detailed results.Final Answer:
Some parts of the request succeeded while others failed -> Option AQuick Check:
HTTP 207 = Partial success [OK]
- Confusing 207 with 200 OK
- Thinking 207 means full failure
- Assuming 207 is a redirect status
Solution
Step 1: Identify correct HTTP status for partial success
HTTP 207 Multi-Status is designed to show multiple results in one response.Step 2: Confirm response format
Using JSON to detail which parts succeeded or failed is the standard approach.Final Answer:
HTTP 207 with JSON detailing success and failure -> Option CQuick Check:
207 + JSON = Partial success response [OK]
- Using 200 OK without details
- Returning 404 for partial success
- Sending server error 500 instead of partial status
{
"responses": [
{"id": 1, "status": "success"},
{"id": 2, "status": "failure", "error": "Invalid data"},
{"id": 3, "status": "success"}
]
}Solution
Step 1: Locate item with ID 3 in JSON
Item with ID 3 has "status": "success" in the responses array.Step 2: Interpret the status value
The status "success" means the operation for item 3 succeeded.Final Answer:
Success -> Option BQuick Check:
ID 3 status = success [OK]
- Confusing failure of other items with this one
- Assuming missing error means failure
- Ignoring the status field
HTTP/1.1 207 Multi-Status
{
"results": [
{"item": "A", "status": "success"},
{"item": "B", "status": "fail", "error": "Timeout"}
]
}
What is the main issue in this response?Solution
Step 1: Check HTTP status code usage
HTTP 207 Multi-Status is correct for partial success.Step 2: Verify status field values
Common practice uses "success" and "failure" or "error"; "fail" is inconsistent and may cause confusion.Final Answer:
The status value "fail" should be "failure" or "error" -> Option DQuick Check:
Status values must be consistent and clear [OK]
- Thinking 207 is wrong here
- Ignoring inconsistent status wording
- Assuming JSON is invalid without checking
Solution
Step 1: Identify the need for partial success reporting
Since some updates succeed and others fail, the response must show both results clearly.Step 2: Choose appropriate HTTP status and response format
HTTP 207 Multi-Status with detailed JSON per user update is the best practice to communicate partial success.Final Answer:
Return HTTP 207 with a JSON array showing each user's update status and error if any -> Option AQuick Check:
207 + detailed JSON = clear partial success [OK]
- Ignoring failed updates in response
- Using 200 OK without details
- Returning generic errors instead of per-item status
Ready to prove it?
Pass the test and this pattern moves unknown
