12

As opposed to SOAP, building a REST service gives you a lot of creative freedom. You can choose your own URI scheming, which content types to use, what HTTP verb to send and which HTTP status code to return.

This causes questions to be asked daily: "What URI pattern should my service use?", "Which HTTP status code to respond with in arbitrary situation X?" and "With what verb should I send this arbitrary request?".

Case in point, a quick handful of questions for the past week:

Such questions hardly ever get more than one answer, where OP seems to want to hold their specific situation against someone else to just hear "Just pick any, it doesn't really matter anyway" or "I would use this status code", where the proposed status code is wrong.

A lot of these questions are thus basically opinion-based, where OP will accept the first opinion they hear.

I would like to do something against these questions, as they're hardly any good, often too localized and the answers are generally opinion-based or wrong, based on a misinterpretation of either the REST manifesto or the HTTP RFCs.

There's plenty of lists of HTTP status codes on the web where it is explained which status code or verbs applies to which situations. Can we, for example, create some canonical Q&As where these aspects of HTTP are explained in understandable terms, so any question that asks the same as thousands before them can be closed as a duplicate of one of those canonicals?

15
  • 3
    They're questions stemming from not understanding the platform you're using, which in the case of REST boils down to the HTTP protocol. Those kind of questions have existed forever in different disguises, if there was no solution for preventing "how to call a PHP function in javascript", I don't see how anything can be done about this.
    – Gimby
    Commented Oct 9, 2015 at 10:49
  • @Gimby there is, it's called a canoncial Q&A. I can't image that for that specific problem there isn't one yet. One can always opt to write one. It just takes a lot of work to do so, and a lot of effort to make answerers point to it instead of repeating its answers.
    – CodeCaster
    Commented Oct 9, 2015 at 11:02
  • 3
    "Can we, for example, create some canonical Q&As where HTTP is explained in understandable terms, and close any question that asks the same as thousands before them can be closed as a duplicate of one of those canonicals?" - yes. Are you asking for help doing so? That's not very clear.
    – jonrsharpe
    Commented Oct 9, 2015 at 11:19
  • 13
    This is a lot like the [regex] and [sql] tags, same questions asked over and over again but never exactly the same and Google never helping out. A canonical Q+A doesn't help either, you just get no end of hassle from the questioners. They don't want a REST tutorial, plenty of those around already. Best way to deal with tags that annoy you is to add them to your Ignored Tags section in your profile. Commented Oct 9, 2015 at 11:25
  • @jonrsharpe yes. No. Maybe. First I'm asking for a discussion whether it's doable. The organization of creating canonicals is sub-par, and getting them known by other answerers too. Maybe I should ask a question about that first.
    – CodeCaster
    Commented Oct 9, 2015 at 11:30
  • 1
    @Hans I agree, but we're never going to get those closed as "too broad" or "opinion-based". I don't even bother voting on them again, as they get answered and my vote ages away. Then I'd rather use my C# closehammer to point them towards a canonical Q&A that can explain the basic issue and point them to further learning resources. Ignoring the REST tag is not an option, I'm interested in those questions in general.
    – CodeCaster
    Commented Oct 9, 2015 at 12:18
  • My 2c. "...whether it's doable?" In theory, yes, but as you say, there's a plethora of such attempts out on the web, so I'd draw two conclusions: (a) it's probably impossible to do one that everyone agrees on (a lot of it is, as you say, a matter of opinion), and (b) even if you/someone did create a succinct, canonical reference, it wouldn't stop people asking questions (although it would be somewhere to close-as-dupe them to).
    – TripeHound
    Commented Oct 9, 2015 at 13:49
  • 2
    Know nothing about the subject, so I might be wrong here, but this looks like a contradiction: "...where the proposed status code is wrong. A lot of these questions are thus basically opinion-based..."
    – Anders
    Commented Oct 9, 2015 at 14:11
  • @Anders "Q: What status code would you use?" - "A: I would use XXX", where XXX is arguably the wrong choice if you properly read the RFC. Opinion-based and wrong.
    – CodeCaster
    Commented Oct 9, 2015 at 14:14
  • 3
    Most people using REST don't really understand it :( Commented Oct 9, 2015 at 16:31
  • 2
    Interesting, if not ironic, that an opinion-based question is necessary in order to address the issue of opinion-based questions ^-^
    – code_dredd
    Commented Oct 11, 2015 at 2:41
  • 1
    As opposed to using an eclectic mix of HTTP verbs and status codes, also valid is to just use only GET/POST, always respond with status 200, and include more descriptive status information in your response data. So where's the canonical Q&A where I can explain to everyone that's using SOAP or a typical RESTful API that they're doing it wrong? In seriousness, I think the subject matter is too wide open. There's not really a canonical answer that can be given to people who ask "what's the best way to leverage HTTP?".
    – aroth
    Commented Oct 12, 2015 at 4:02
  • @ray it's a discussion question... But I'm sure that the people closing to vote this one as opinion-based are willing to answer the daily stream of such REST questions.
    – CodeCaster
    Commented Oct 12, 2015 at 5:36
  • Hi @CodeCaster. The comment was meant to be tongue-in-cheek and you seem to have missed the humorous side of it.
    – code_dredd
    Commented Oct 12, 2015 at 6:27
  • @ray sure, but now it's closed. The consensus seems to be "there isn't a problem" or "go write some canonicals", so that's fine.
    – CodeCaster
    Commented Oct 12, 2015 at 6:35

3 Answers 3

7

"How does HTTP work" is probably going to be too broad.

The answer will either be too long or massively incomplete.

Instead, find a smaller clump of questions. Find the general problem that is narrower than "how does HTTP work", yet solves those problems. Create a high-quality question (with a concrete, practical example in it -- or more than one).

Generate a high-quality answer to the question, that has a tutorial on how to solve the problem, and an example of solving the particular case.

Now we have a sufficiently narrow, practical solution to that class of problems.

Make sure this lines up with the culture of your tags.

Assuming it is well received, you now have a valid and useful Mjölnir target for that class of problems.

Test it out. Use it on someone who asks that kind of question before they get an answer, and ask if that solves their problem. Improve it to make it work better.

Next, iterate. Find a set of problems which your Mjölnir doesn't apply, or only applies marginally. Is there a nice and narrow problem you can write that will answer those problems?

Making a general "what are the HTTP status codes" and listing them all and their purpose, and linking any question about "what HTTP status code should I use" to that question, is a poor idea. The question and the answer there are of poor quality, and it is unlikely to actually help someone that much. That would be an attempt at a "too broad" solution, in my opinion.

2
  • 1
    I reworded "How does HTTP work" already in my question. I am looking for a way to end the endless discussions of "Which HTTP status code to use" which are never answered thoroughly and almost every time only apply to OP's specific situation - if they even are correct. A canonical Q&A that lists all existing status codes and explains which example situations apply to them would be too long. If we agree that the question "Which HTTP status code to use" is a poor question, then we should collectively decide so and close such questions uniformly.
    – CodeCaster
    Commented Oct 9, 2015 at 13:57
  • @CodeCaster "Which HTTP status code should I use when relation is not existing, yet the URL is properly formatted?" is narrower than "Which HTTP status code should I use?". The second is too broad. The first can actually be answered, and is a concrete problem. Try to find something between the two (a bit broader), and use that. If you want to teach how to pick the right code, find a medium broad situation, and have a tutorial on how to work your way through the code list for that problem. Commented Oct 9, 2015 at 14:14
17

None of these questions are particularly egregious in their content. They're reasonably well written, mostly demonstrate some knowledge of the subject (i.e. OP has done some research) and that the OP is actually trying to think through their problem.

Nothing in programming and development is black and white, especially with REST. There's always a margin of opinion and I think these questions stay within the margins of what's acceptable on Stack Overflow.

There are far worse questions to be getting annoyed about than these which are being asked in good faith, as opposed to the usual "plz send teh codes" crap.

If your aim is to close as a dupe of a canonical answer, then why not write one up yourself.

3
  • 1
    I'm not being annoyed, I want to point them to a better resource than the opinion of the answerer who happens to run by the question at the moment it is posted. It is often based on some interpretation of the relevant RFCs.
    – CodeCaster
    Commented Oct 9, 2015 at 14:31
  • 2
    @CodeCaster - then why not write up that "better resource" yourself, or better still explain in the answer comments what is wrong with that particular interpretation of the RFC's, or just answer the questions yourself.
    – Kev
    Commented Oct 9, 2015 at 14:34
  • "If your aim is to close as a dupe of a canonical answer, then why not write one up yourself" - that takes a lot of effort, and if there's not being linked to by others because they don't know about its existence it's of little use. Like being said in comments, perhaps I should ask a separate question (or do more research) about how to coordinate that work with other members.
    – CodeCaster
    Commented Oct 9, 2015 at 14:34
6

Many of these questions have very good answers. The following are all answers about the 'status code' problem:

Some of the people who ask these questions are misguided or annoying. But they often get very good help from people who know a lot about HTTP and how it SHOULD and MUST work. I understand that this is what we are supposed to be optimizing for.

4
  • 2
    Let me make it clear that I'm not calling these askers annoying, I'm just looking for a way to point them to a good resource as opposed to getting the opinion of the answerer who happens to read their question at the moment. HTTP is hard to get right.
    – CodeCaster
    Commented Oct 9, 2015 at 14:20
  • Asking questions about things you really care about and getting an answer from whoever happens to see them on SO is uh, kind of how it works.
    – jwg
    Commented Oct 9, 2015 at 15:56
  • Very funny, but you're missing the point. I'm talking about polling for opinions, or getting opinion-based answers as opposed to correct answers based on facts, which happens more than you think in the category of question I'm talking about here and which is not the purpose of this site. You're linking to great examples of how it should be done, but the Q&As that were posted in the last week that I link to are not that great and could be better answered.
    – CodeCaster
    Commented Oct 9, 2015 at 16:00
  • 1
    What do you seriously want to happen to these questions? Why don't you answer these questions with (whatever you think is) the right answer? Do you need something other than this to solve your problem?
    – jwg
    Commented Oct 10, 2015 at 6:28

Not the answer you're looking for? Browse other questions tagged .