Use 200 or 400 Status Code When...

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Use 200 or 400 Status Code When...

Randy Syring
I have a page that accepts URL arguments like:

/student/<id>

The id must be an integer or the URL doesn't match and the user is given
a 404.  But what should I do if the id is given, is an integer, but a
student with that id does not exist?  I already output a message telling
the user that they requested an invalid student.  However, should that
document have a 200 or 400 (or some other) status code?

Thanks.

--
--------------------------------------
Randy Syring
RCS Computers & Web Solutions
502-644-4776
http://www.rcs-comp.com

"Whether, then, you eat or drink or
whatever you do, do all to the glory
of God." 1 Cor 10:31

_______________________________________________
Web-SIG mailing list
[hidden email]
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: http://mail.python.org/mailman/options/web-sig/lists%40nabble.com
Reply | Threaded
Open this post in threaded view
|

Re: Use 200 or 400 Status Code When...

Thomas Broyer-2
On Mon, Apr 27, 2009 at 4:32 AM, Randy Syring <[hidden email]> wrote:
> I have a page that accepts URL arguments like:
>
> /student/<id>
>
> The id must be an integer or the URL doesn't match and the user is given a
> 404.  But what should I do if the id is given, is an integer, but a student
> with that id does not exist? I already output a message telling the user
> that they requested an invalid student.  However, should that document have
> a 200 or 400 (or some other) status code?

Obviously a 404 too, as the URL identifies something that doesn't exist.

(in the case of an invalid id, i.e. not a number, you could use 410
status code too)

--
Thomas Broyer
_______________________________________________
Web-SIG mailing list
[hidden email]
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: http://mail.python.org/mailman/options/web-sig/lists%40nabble.com
Reply | Threaded
Open this post in threaded view
|

Re: Use 200 or 400 Status Code When...

Randy Syring
Thomas,

Unfortunately, it wasn't obvious to me that a 404 was appropriate in this situation.  But, now that you mention it, I think you are right.  Thank you for your input.
--------------------------------------
Randy Syring
RCS Computers & Web Solutions
502-644-4776
http://www.rcs-comp.com

"Whether, then, you eat or drink or 
whatever you do, do all to the glory
of God." 1 Cor 10:31


Thomas Broyer wrote:
On Mon, Apr 27, 2009 at 4:32 AM, Randy Syring [hidden email] wrote:
  
I have a page that accepts URL arguments like:

/student/<id>

The id must be an integer or the URL doesn't match and the user is given a
404.  But what should I do if the id is given, is an integer, but a student
with that id does not exist? I already output a message telling the user
that they requested an invalid student.  However, should that document have
a 200 or 400 (or some other) status code?
    

Obviously a 404 too, as the URL identifies something that doesn't exist.

(in the case of an invalid id, i.e. not a number, you could use 410
status code too)

  

_______________________________________________
Web-SIG mailing list
[hidden email]
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: http://mail.python.org/mailman/options/web-sig/lists%40nabble.com