Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools REST API Basics Getting the REST You Need Responses

Is 202 appropriate for the error code on this video? 201 seems more correct for a normal web app.

201 Created 202 Accepted

My understanding is 202 is generally for event stream processors and other types of systems that have some input lag between data receipt and data persistance/system effect.

Yeah, "error code" was a typo. "status code"

2 Answers

Mohsen Qaddoura
Mohsen Qaddoura
22,237 Points

First, let's clarify that the 200-299 are not 'error' codes, they are server response status codes expressing the success of receiving and understanding the requester request and a server action has been taken. Then they must provide some feedback information of the server action about the client specific request.

But still you have got a point here, as per the video, the 202 means the resource has been created as per the request, which it is not, that would be confirmed by the code 201. 202 is more like the server responding to the client with : noted but I will process your request later, you do not need to maintain/persist the connection. And it must also clarify how it will notify the requester with the final status of the request to create the resource. For more specific standards on all codes including more detailed quoting of the standards on these two codes you can check the official w3 protocols here :

https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

And for information about the W3 itself, the community setting the standards for the web, including the standards mentioned above, and is led by the inventor of the web himself, Tim Berners-Lee check :

https://www.w3.org/Consortium/

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Yeah, so, that's all me. I'm gonna see about getting a fix.