Bird
Raised Fist0
Rest APIprogramming~20 mins

Partial success handling in Rest API - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Partial Success Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
1:00remaining
What is the HTTP status code for partial success in REST APIs?

In REST API design, which HTTP status code best represents a partial success response?

A207 Multi-Status
B500 Internal Server Error
C404 Not Found
D200 OK
Attempts:
2 left
💡 Hint

Think about a status code that can represent multiple outcomes in one response.

❓ Predict Output
intermediate
1:00remaining
What is the output of this partial success JSON response?

Given this JSON response from a REST API after batch processing, what is the value of results[1].status?

{
  "results": [
    {"id": 1, "status": "success"},
    {"id": 2, "status": "failed", "error": "Invalid input"},
    {"id": 3, "status": "success"}
  ]
}
A"failed"
Bnull
C"success"
D"pending"
Attempts:
2 left
💡 Hint

Look carefully at the second item in the results array.

🧠 Conceptual
advanced
1:30remaining
Which approach best handles partial success in batch REST API calls?

When a batch REST API call partially succeeds, which approach is best to inform the client?

AReturn HTTP 500 to indicate failure of the entire batch
BReturn HTTP 404 if any item is not found
CReturn HTTP 200 with a detailed body showing success and failure per item
DReturn HTTP 204 No Content with no details
Attempts:
2 left
💡 Hint

Consider how to communicate both successes and failures clearly.

🔧 Debug
advanced
1:30remaining
Identify the error in this partial success response handler code snippet

What error will this Python Flask code produce when handling partial success?

from flask import Flask, jsonify
app = Flask(__name__)

@app.route('/batch', methods=['POST'])
def batch_process():
    results = [{"id": 1, "status": "success"}, {"id": 2, "status": "failed"}]
    if any(r['status'] == 'failed' for r in results):
        return jsonify(results), 207
    else:
        return jsonify(results), 200

if __name__ == '__main__':
    app.run()
ARuntimeError because jsonify cannot serialize list of dicts
BNo error; code runs and returns 207 status with JSON
CSyntaxError due to missing colon after if statement
DTypeError because 207 is not a valid HTTP status code in Flask
Attempts:
2 left
💡 Hint

Check if Flask supports status code 207 and if jsonify can handle the data.

🚀 Application
expert
1:30remaining
How many items are in the final success list after partial success filtering?

Given this Python code that filters partial success results, how many items remain in success_items?

responses = [
    {"id": 1, "status": "success"},
    {"id": 2, "status": "failed"},
    {"id": 3, "status": "success"},
    {"id": 4, "status": "failed"},
    {"id": 5, "status": "success"}
]
success_items = [r for r in responses if r['status'] == 'success']
print(len(success_items))
A0
B2
C5
D3
Attempts:
2 left
💡 Hint

Count how many items have status 'success'.

Practice

(1/5)
1. What does HTTP 207 Multi-Status indicate in REST API partial success handling?
easy
A. Some parts of the request succeeded while others failed
B. The entire request failed due to server error
C. The request was redirected to another URL
D. The request was successful with no errors

Solution

  1. Step 1: Understand HTTP 207 Multi-Status meaning

    HTTP 207 is used to report multiple status codes for different parts of a single request.
  2. Step 2: Relate to partial success handling

    This status code indicates that some parts succeeded and others failed, providing detailed results.
  3. Final Answer:

    Some parts of the request succeeded while others failed -> Option A
  4. Quick Check:

    HTTP 207 = Partial success [OK]
Hint: 207 means mixed results, not full success or failure [OK]
Common Mistakes:
  • Confusing 207 with 200 OK
  • Thinking 207 means full failure
  • Assuming 207 is a redirect status
2. Which of the following is the correct way to represent partial success in a REST API response?
easy
A. HTTP 404 with error message
B. HTTP 200 with empty body
C. HTTP 207 with JSON detailing success and failure
D. HTTP 500 with stack trace

Solution

  1. Step 1: Identify correct HTTP status for partial success

    HTTP 207 Multi-Status is designed to show multiple results in one response.
  2. Step 2: Confirm response format

    Using JSON to detail which parts succeeded or failed is the standard approach.
  3. Final Answer:

    HTTP 207 with JSON detailing success and failure -> Option C
  4. Quick Check:

    207 + JSON = Partial success response [OK]
Hint: Use 207 with JSON for partial success, not 200 or errors [OK]
Common Mistakes:
  • Using 200 OK without details
  • Returning 404 for partial success
  • Sending server error 500 instead of partial status
3. Given this partial success JSON response, what is the status of item with ID 3?
{
  "responses": [
    {"id": 1, "status": "success"},
    {"id": 2, "status": "failure", "error": "Invalid data"},
    {"id": 3, "status": "success"}
  ]
}
medium
A. Failure due to invalid data
B. Success
C. Unknown status
D. Pending

Solution

  1. Step 1: Locate item with ID 3 in JSON

    Item with ID 3 has "status": "success" in the responses array.
  2. Step 2: Interpret the status value

    The status "success" means the operation for item 3 succeeded.
  3. Final Answer:

    Success -> Option B
  4. Quick Check:

    ID 3 status = success [OK]
Hint: Check the status field for the item ID in JSON [OK]
Common Mistakes:
  • Confusing failure of other items with this one
  • Assuming missing error means failure
  • Ignoring the status field
4. You receive this HTTP response code and body from a batch update API:
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?
medium
A. Incorrect HTTP status code for partial success
B. JSON format is invalid
C. Missing Content-Type header
D. The status value "fail" should be "failure" or "error"

Solution

  1. Step 1: Check HTTP status code usage

    HTTP 207 Multi-Status is correct for partial success.
  2. Step 2: Verify status field values

    Common practice uses "success" and "failure" or "error"; "fail" is inconsistent and may cause confusion.
  3. Final Answer:

    The status value "fail" should be "failure" or "error" -> Option D
  4. Quick Check:

    Status values must be consistent and clear [OK]
Hint: Use standard status words like 'success' and 'failure' [OK]
Common Mistakes:
  • Thinking 207 is wrong here
  • Ignoring inconsistent status wording
  • Assuming JSON is invalid without checking
5. You design a REST API endpoint that processes a list of user updates. Some updates succeed, others fail due to validation errors. How should you structure the response to clearly communicate partial success?
hard
A. Return HTTP 207 with a JSON array showing each user's update status and error if any
B. Return HTTP 400 with a generic error message for all failures
C. Return HTTP 200 with a simple success message ignoring failures
D. Return HTTP 500 with server error details

Solution

  1. Step 1: Identify the need for partial success reporting

    Since some updates succeed and others fail, the response must show both results clearly.
  2. 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.
  3. Final Answer:

    Return HTTP 207 with a JSON array showing each user's update status and error if any -> Option A
  4. Quick Check:

    207 + detailed JSON = clear partial success [OK]
Hint: Use 207 and detailed JSON for mixed success/failure results [OK]
Common Mistakes:
  • Ignoring failed updates in response
  • Using 200 OK without details
  • Returning generic errors instead of per-item status
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard