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

If it’s for a well-defined and -documented API, 202 sounds exactly right for what’s happening. If it’s for the public Internet, I would be too worried about client compatibility. I’ve seen so many if (status == 200) hard-coded…. In that case, I would return a 200. Also, the RFC makes no indication that using 202 … Read more

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

Curl has a specific option, –write-out, for this: $ curl -o /dev/null –silent –head –write-out ‘%{http_code}\n’ <url> 200 -o /dev/null throws away the usual output –silent throws away the progress meter –head makes a HEAD HTTP request, instead of GET –write-out ‘%{http_code}\n’ prints the required status code To wrap this up in a complete Bash … Read more

Convention for HTTP response header to notify clients of deprecated API

I would not change anything in the status code to be backward compatible. I would add a “Warning” header in the response : Warning: 299 – “Deprecated API” You can also specify the “-” with the “Agent” that emits the warning, and be more explicit in the warn-text : Warning: 299 api.blazingFrog.com “Deprecated API: use … Read more

Laravel – Return json along with http status code

You can use http_response_code() to set HTTP response code. If you pass no parameters then http_response_code will get the current status code. If you pass a parameter it will set the response code. http_response_code(201); // Set response status code to 201 For Laravel(Reference from: https://stackoverflow.com/a/14717895/2025923): return Response::json([ ‘hello’ => $value ], 201); // Status code … Read more

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

Under Apache, the limit is a configurable value, LimitRequestLine. Change this value to something larger than its default of 8190 if you want to support a longer request URI. The value is in /etc/apache2/apache2.conf. If not, add a new line (LimitRequestLine 10000) under AccessFileName .htaccess. However, note that if you’re actually running into this limit, … Read more

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

You should use 400 for business rules. Don’t return 2xx if the order was not accepted. HTTP is an application protocol, never forget that. If you return 2xx the client can assume the order was accepted, regardless of any information you send in the body. From RESTful Web Services Cookbook: One common mistake that some … Read more