Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8822445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:06:32+00:00 2026-06-14T06:06:32+00:00

Let’s say you want to get list of users by calling GET to api/users

  • 0

Let’s say you want to get list of users by calling GET to api/users, but currently the table was truncated so there are no users. What is the proper response for this scenario: 404 or 204?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:06:33+00:00Added an answer on June 14, 2026 at 6:06 am

    I’d say, neither.

    Why not 404 (Not Found) ?

    The 404 status code should be reserved for situations, in which a resource is not found. In this case, your resource is a collection of users. This collection exists but it’s currently empty. Personally, I’d be very confused as an author of a client for your application if I got a 200 one day and a 404 the next day just because someone happened to remove a couple of users. What am I supposed to do? Is my URL wrong? Did someone change the API and neglect to leave a redirection.

    Why not 204 (No Content) ?

    Here’s an excerpt from the description of the 204 status code by w3c

    The server has fulfilled the request but does not need to return an entity-body, and might want to return updated metainformation.

    While this may seem reasonable in this case, I think it would also confuse clients. A 204 is supposed to indicate that some operation was executed successfully and no data needs to be returned. This is perfect as a response to a DELETE request or perhaps firing some script that does not need to return data. In case of api/users, you usually expect to receive a representation of your collection of users. Sending a response body one time and not sending it the other time is inconsistent and potentially misleading.

    Why I’d use a 200 (OK)

    For reasons mentioned above (consistency), I would return a representation of an empty collection. Let’s assume you’re using XML. A normal response body for a non-empty collection of users could look like this:

    <users>
      <user>
        <id>1</id>
        <name>Tom</name>
      </user>
      <user>
        <id>2</id>
        <name>IMB</name>
      </user>
    </users>
    

    and if the list is empty, you could just respond with something like this (while still using a 200):

    <users/>
    

    Either way, a client receives a response body that follows a certain, well-known format. There’s no unnecessary confusion and status code checking. Also, no status code definition is violated. Everybody’s happy.

    You can do the same with JSON or HTML or whatever format you’re using.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I don't have photoshop, but I want to make pattern files (.pat)
Let's say I have thousands of users and I want to make the passwords
Let say I want to test my controller behavior, but it accepts JSON string
Let's say I have a table with a Color column. Color can have various
Let's say I have a sortable list like this: $(.song-list).sortable({ handle : '.pos_handle', axis
Let's say I have the following entity: public class Store { public List<Product> Products
let's say I have a select list as follows: <select name='languages'> <option value='german'>German</option> <option
Let say I've this URL: http://example.com/image-title/987654/ I want to insert download to the part
Let's say I can call a method like this: core::get() . What is the
Let's say I have the following text: (example) <table> <tr> <td> <span>col1</span> </td> <td>col2</td>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.