Questions tagged [http-status-codes]

HTTP status codes are a set of standardized codes returned in an HTTP web response. Questions about why a service is (unexpectedly) returning a status code should not use this tag.

For a full list of the status codes see the HTTP 1.1 specification, WebDAV specification, RFC 6585, and the IANA list of status codes.

HTTP status codes have specific meanings which are outlined in the specification that they were created in. They can be used in contexts outside of what the specification states, but must adhere to any conditions that have been established in the specification.

1693 questions
193
votes
7 answers

Create request with POST, which response codes 200 or 201 and content

Suppose I write a REST service whose intent is to add a new data item to a system. I plan to POST to http://myhost/serviceX/someResources Suppose that works, what response code should I use? And what content might I return. I'm looking at the…
djna
  • 54,992
  • 14
  • 74
  • 117
190
votes
5 answers

What's the appropriate HTTP status code to return if a user tries logging in with an incorrect username / password, but correct format?

A similar question is posted here: What's an appropriate HTTP status code to return by a REST API service for a validation failure? The answer in the thread above states that "For instance if the URI is supposed to have an ISO-8601 date and you find…
187
votes
9 answers

What's the most appropriate HTTP status code for an "item not found" error page

I'm curious what's the most appropriate HTTP status code for an "item does not exist" page. If the page itself doesn't exist, I'll obviously use 404. However, one of my pages has a userid argument (it's an "edit user" page) and in case no user with…
ThiefMaster
  • 310,957
  • 84
  • 592
  • 636
185
votes
9 answers

Throw HttpResponseException or return Request.CreateErrorResponse?

After reviewing an article Exception Handling in ASP.NET Web API I am a bit confused as to when to throw an exception vs return an error response. I am also left wondering whether it is possible to modify the response when your method returns a…
zam6ak
  • 7,229
  • 11
  • 46
  • 84
179
votes
4 answers

What is correct HTTP status code when redirecting to a login page?

When a user is not logged in and tries to access a page that requires login, what is the correct HTTP status code for a redirect to the login page? I am asking because none of the 3xx response codes set out by the W3C seem to fit the…
Vidar Vestnes
  • 42,644
  • 28
  • 86
  • 100
174
votes
6 answers

System.Net.WebException HTTP status code

Is there an easy way to get the HTTP status code from a System.Net.WebException?
Gilsham
  • 2,276
  • 2
  • 13
  • 14
169
votes
2 answers

Difference between HTTP redirect codes

The differences between the various HTTP 3XX redirect codes are not clear to me. Yes, I've read the spec, but there seems to be some discrepancy between the standard and actual practice here. The 301 redirect code seems clear enough: This means the…
Channel72
  • 24,139
  • 32
  • 108
  • 180
163
votes
12 answers

How to get HTTP response code for a URL in Java?

Please tell me the steps or code to get the response code of a particular URL.
Ajit
  • 1,639
  • 2
  • 11
  • 3
155
votes
6 answers

HTTP status code for a partial successful request

I have an application that sends messages to users. In a post request a XML string is transferred that consists of all the users that should receive that particular message. If any of the users in the list do not exist I give the list of missing…
Norbert Hartl
  • 10,481
  • 5
  • 36
  • 46
152
votes
22 answers

Why is AJAX returning HTTP status code 0?

For some reason, while using AJAX (with my dashcode developed application) the browser just stops uploading and returns status codes of 0. Why does this happen?
tarnfeld
  • 25,992
  • 41
  • 111
  • 146
146
votes
7 answers

What is the appropriate HTTP status code response for a general unsuccessful request (not an error)?

I'm creating a RESTful API that will process a number of user interactions, including placing orders using stored credit cards. In the case of a successful order, I'm returning a 200 OK, and in the case where the order request is malformed or…
Raelshark
  • 2,975
  • 3
  • 27
  • 36
143
votes
4 answers

In Python, how do I use urllib to see if a website is 404 or 200?

How to get the code of the headers through urllib?
TIMEX
  • 259,804
  • 351
  • 777
  • 1,080
124
votes
6 answers

How do I resolve a HTTP 414 "Request URI too long" error?

I have developed a PHP web app. I am giving an option to the user to update multiple issues on one go. In doing so, sometimes the user is encountering this error. Is there any way to increase the lenght of URL in apache?
JPro
  • 6,292
  • 13
  • 57
  • 83
119
votes
10 answers

Laravel - Return json along with http status code

If I return an object: return Response::json([ 'hello' => $value ]); the status code will be 200. How can I change it to 201, with a message and send it with the json object?. I don't know if there is a way to just set the status code in…
Galivan
  • 4,842
  • 9
  • 44
  • 76
115
votes
13 answers

HTTP status code 0 - Error Domain=NSURLErrorDomain?

I am working on an iOS project. In this application, I am downloading images from the server. Problem: While downloading images I am getting Request Timeout. According to documentation HTTP status code of request timeout is 408. But in my…
Irfan DANISH
  • 8,349
  • 12
  • 42
  • 67