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
108
votes
6 answers

Convention for HTTP response header to notify clients of deprecated API

I'm upgrading our REST API endpoints and I want to notify clients when they are calling the to-be-deprecated endpoint. What header should I use in the response with a message along the lines of "This API version is being deprecated, please consult…
BlazingFrog
  • 2,265
  • 3
  • 21
  • 31
105
votes
9 answers

Script to get the HTTP status code of a list of urls?

I have a list of URLS that I need to check, to see if they still work or not. I would like to write a bash script that does that for me. I only need the returned HTTP status code, i.e. 200, 404, 500 and so forth. Nothing more. EDIT Note that there…
Manu
  • 4,410
  • 6
  • 43
  • 77
102
votes
3 answers

HTTP Status 424 or 500 for error on external dependency

I am trying to create a service that has 2 dependencies. One of the dependencies is internally managed while the 2nd requires an external http outbound call to a third party API. The sequence requires the updating the resource and then executing the…
geneqew
  • 2,401
  • 5
  • 33
  • 48
100
votes
5 answers

HTTP Get with 204 No Content: Is that normal

Is it a normal occurrence for an HTTP GET Request to have a response with status code 204 - No Content? Like, is this semantically correct concerning what an HTTP GET is supposed to accomplish? I know that a 204 - No Content is okay for an HTTP…
ecbrodie
  • 11,246
  • 21
  • 71
  • 120
99
votes
6 answers

Set Response Status Code

I have an API call for which I need to be able to run some checks and potentially return various status codes. I don't need custom views or anything, I just need to return the proper code. If the user hasn't passed proper credentials, I need to…
Rob Wilkerson
  • 40,476
  • 42
  • 137
  • 192
99
votes
4 answers

Is it wrong to return 202 "Accepted" in response to HTTP GET?

I have a set of resources whose representations are lazily created. The computation to construct these representations can take anywhere from a few milliseconds to a few hours, depending on server load, the specific resource, and the phase of the…
user359996
  • 5,533
  • 4
  • 33
  • 24
95
votes
1 answer

HTTP status code for temporarily unavailable pages

I'm redesigning my small business' website. I will be putting up a temporarily 'under construction' splash page. I know, I know... but it will be one in style, I hope. :) What, mostly for SEO purposes, is the best HTTP status code to dish out for…
Decent Dabbler
  • 22,532
  • 8
  • 74
  • 106
94
votes
4 answers

Is it correct to return 404 when a REST resource is not found?

Let's say I have a simple (Jersey) REST resource as follows: @Path("/foos") public class MyRestlet extends BaseRestlet { @GET @Path("/{fooId}") @Produces(MediaType.APPLICATION_XML) public Response getFoo(@PathParam("fooId")…
carlspring
  • 31,231
  • 29
  • 115
  • 197
93
votes
1 answer

Should a 502 HTTP status code be used if a proxy receives no response at all?

According to the RFC: 10.5.3 502 Bad Gateway The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request. Can invalid response also mean no response at…
primroot
  • 1,686
  • 1
  • 15
  • 17
92
votes
3 answers

Android: How get the status-code of an HttpClient request

I want to download a file and need to check the response status code (ie HTTP /1.1 200 OK). This is a snipped of my code: HttpGet httpRequest = new HttpGet(myUri); HttpEntity httpEntity = null; HttpClient httpclient = new…
whlk
  • 15,487
  • 13
  • 66
  • 96
91
votes
11 answers

What http status code is supposed to be used to tell the client the session has timed out?

In a webpage, it uses YUI connection manager/datasource to send AJAX requests to the server, if the session (which contains the info on whether the user has been authenticated) has already timed out, those ajax responses that can only be viewed by…
bobo
  • 8,439
  • 11
  • 57
  • 81
89
votes
2 answers

REST HTTP status code if DELETE impossible

My question is quite a generic one about HTTP status code when a DELETE is impossible on the resource (but not regarding user's rights). We have a RESTful API on a type of resource. The DELETE method is authorized on the resource however under some…
Matt
  • 3,422
  • 1
  • 23
  • 28
86
votes
3 answers

Return a specific http status code in Rails

How do you return 503 Service Unavailable in Rails for the entire application? Also, how do you do the same for specific controllers?
85
votes
9 answers

How do I get the HTTP status code with jQuery?

I want to check if a page returns the status code 401. Is this possible? Here is my try, but it only returns 0. $.ajax({ url: "http://my-ip/test/test.php", data: {}, complete: function(xhr, statusText){ alert(xhr.status); …
horgen
  • 2,183
  • 10
  • 30
  • 34
73
votes
3 answers

When is it appropriate to respond with a HTTP 412 error?

It is unclear to me when you should and should not return a HTTP 412: Precondition Failed, error for a web service? I am thinking of using it when validating data. For example, if a client POST's XML data and that data is missing a required data…
TERACytE
  • 7,553
  • 13
  • 75
  • 111