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

  • Home
  • SEARCH
  • 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 8610585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:10:11+00:00 2026-06-12T04:10:11+00:00

I have a normal, basic REST api like: / GET – list POST –

  • 0

I have a normal, basic REST api like:

/
    GET - list
    POST - create

/<id>
    GET - detail
    PUT - replace
    PATCH - patch
    DELETE - delete

When a POST comes in to /, I usually create an object and make a new id. Some (one) of the fields are (is) required to be unique. So, a POST with such duplicate data could result in:

  1. 500 – IntegrityError
  2. Make it more like a PUT/PATCH to /<id> and update the existing record
  3. Catch/avoid the error and return some sort of 4XX
  4. Something else I’m not thinking of.

1 seems out: the request is either bad or I can deal with it. What is the correct way to handle this situation?

  • 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-12T04:10:13+00:00Added an answer on June 12, 2026 at 4:10 am

    @StevenFisher is correct. 409 Conflict is the correct response.

    The request could not be completed due to a conflict with the current
    state of the resource. This code is only allowed in situations where
    it is expected that the user might be able to resolve the conflict and
    resubmit the request. The response body SHOULD include enough
    information for the user to recognize the source of the conflict.
    Ideally, the response entity would include enough information for the
    user or user agent to fix the problem; however, that might not be
    possible and is not required.

    For instance, a GET on / might tell a client that they can create users as follows

    HTTP/1.1 200 OK
    <users href="/">
        <create href="/" method="post">
            <username type="xs:token" cardinality="required"/>
            <password type="password" cardinality="required"/>
        </create>
        ... other hypermedia controls, like search ...
    </users>
    

    Following the hypermedia control and trying to create a user with the username “Skylar Saveland” might result in

    HTTP/1.1 409 Conflict
    <users href="/">
        <create href="/" method="post">
            <username type="xs:token" cardinality="required" 
                      error="The username 'Skylar Saveland' is already taken. Please select another username"/>
            <password type="password" cardinality="required"/>
        </create>
        ... other hypermedia controls, like search ...
    </users>
    

    Similarly, trying to create a user without a password might result in

    HTTP/1.1 409 Conflict
    <users href="/">
        <create href="/" method="post">
            <username type="xs:token" cardinality="required"/>
            <password type="password" cardinality="required" 
                      error="A password must be specified"/>
        </create>
        ... other hypermedia controls, like search ...
    </users>
    

    or you might have multiple errors, e.g.,

    HTTP/1.1 409 Conflict
    <users href="/">
        <create href="/" method="post">
            <username type="xs:token" cardinality="required"
                      error="The username 'Skylar Saveland' is already taken. Please select another username"/>
            <password type="password" cardinality="required"
                      error="A password must be specified"/>
        </create>
        ... other hypermedia controls, like search ...
    </users>
    

    NOTE: An appropriate media type will need to be created to go along with the above, which will explain the structure of the hypermedia controls (including the error attributes on the forms) and define the meaning of the various element names (e.g., users, username, password, etc).

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

Sidebar

Related Questions

My forms have checkboxes and I would like to replace the normal arrow check
I have basic idea about running PHP in different configurations like mod_php, cgi, FastCGI,
I have basic single page website with the normal Google Analytic code: var _gaq
currently i have jdbc code with the following basic stucture: get Connection (do the
This is a basic question I'm sure.... I have a normal form, but one
I have normal sqlite database and want to use fts3. As mentioned in http://www.sqlite.org/fts3.html
I have a normal NavigationController. When i open one modalView (using segues) and dismiss
I have a normal textbox in my application. I can paste data to it
I have a normal asp.net page containing some code that I want to measure
I have a normal UINavigationController with a UIViewController contained in it, when my view

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.