Bird
0
0

You want to design a REST API endpoint for a long-running image processing task. Which approach best follows async response principles?

hard📝 Application Q15 of 15
Rest API - Advanced Patterns
You want to design a REST API endpoint for a long-running image processing task. Which approach best follows async response principles?
AClient POSTs image, server returns 202 Accepted with a status URL; client polls status URL until done.
BClient POSTs image, server processes image immediately and returns 200 OK with result.
CClient POSTs image, server returns 404 Not Found if task is slow.
DClient POSTs image, server holds connection open until processing finishes.
Step-by-Step Solution
Solution:
  1. Step 1: Understand async response design

    Server accepts task, returns 202 with status URL for client to poll progress.
  2. Step 2: Evaluate other options

    Immediate processing (200 OK) blocks client; 404 is wrong status; holding connection open blocks client.
  3. Final Answer:

    Client POSTs image, server returns 202 Accepted with a status URL; client polls status URL until done. -> Option A
  4. Quick Check:

    Async design = 202 + status URL + polling [OK]
Quick Trick: Async = 202 + status URL + client polls [OK]
Common Mistakes:
MISTAKES
  • Returning 200 OK immediately for slow tasks
  • Using 404 for slow processing
  • Keeping connection open until done

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes