0

I'am writing an API to make users can subscribe to things. An user can subscribe to anything via submitting a POST something like this:

{
    "item_id": "c13",
    "requested_status": "subscriber",
    "sure": true,
}

Here you can see a sure parameter. I'am using this to avoid making subscriptions accidentaly. If client sends that info without sure parameter API rejects that request to make GUI ask "are sure to subscribe this?". If user confirms, same post happens again with sure parameter. And subscription (or unsubscription) happens.

So, when I am rejecting that request because there is no sure parameter. Which response code should I use? I thought 400 (bad request) can be used but not sure.

Thanks for you response.

dur
  • 15,689
  • 25
  • 79
  • 125
Mirat Can Bayrak
  • 631
  • 7
  • 18

1 Answers1

1

HTTP codes are codes with a pure technical meaning. What you want is not a technical problem and shouldn't be handled with technical means.

Since the reponse was received and contained technically correct values (not the same as functional valid values!), you should send a 200 - OK status. The content of your response should be the action to perform next. In this case, ask the user if he/she is sure.

If you work with Post-Redirect-Get, a 303 - See Other status is your best option.

Jeroen
  • 979
  • 1
  • 7
  • 16
  • You might want to check this URL: http://odino.org/don-t-rape-http-if-none-match-the-412-http-status-code/. It is when a pre-condition in the HTTP header was not satisfied. – Jeroen Jul 17 '12 at 11:29