CS FundamentalsModerateGATE CS · Product company CS fundamentals

A REST API creates a resource in response to a POST. Which response is most appropriate?

  1. A. 200 OK with no body
  2. B. 201 Created with a Location header pointing to the new resource
  3. C. 204 No Content with the new ID in the body
  4. D. 302 Found to the collection URL

Correct answer: B. 201 Created with a Location header pointing to the new resource

201 tells the client that a new resource exists and Location gives its URL. 204 means success with no body at all, and redirects (3xx) are for moving the client elsewhere, not for reporting creation.

More Computer Networks questions

Exams that ask this topic