Questions tagged [http-status-code-200]

200 OK The request has succeeded.

200 OK

The request has succeeded. The information returned with the response is dependent on the method used in the request, for example:

GET an entity corresponding to the requested resource is sent in the response;

HEAD the entity-header fields corresponding to the requested resource are sent in the response without any message-body;

POST an entity describing or containing the result of the action;

TRACE an entity containing the request message as received by the end server.
(source)

67 questions
120
votes
8 answers

Returning http 200 OK with error within response body

I'm wondering if it is correct to return HTTP 200 OK when an error occurred on the server side (the error details would be contained inside the response body). Example: We're sending HTTP GET Something unexpected happened on the server side. Server…
krzakov
  • 3,871
  • 11
  • 37
  • 52
9
votes
2 answers

Normal to see Status 204 then Status 200?

I am looking at my ajax request in network tab in chrome and I noticed every ajax request I do happens twice. First one is a 204 and then followed up with 200. My ajax call is only being hit once so I am not sure why there are 2. Edit So it seems to…
chobo2
  • 83,322
  • 195
  • 530
  • 832
7
votes
1 answer

HTTP GET 200 vs 204

We are designing a public API, and trying to figure out what is the best practice for GET with following cases: Path param: /orders/{orderId} Found: 200 with a response body. Not Found: 404. Query…
6
votes
5 answers

Cache-Control not returning 304

I have a website with static assets that don't change (js, images, etc). Each of these assets has the cache-control header set with the following property: cache-control: public, max-age=31536000, immutable However, when I reload the page I'm still…
tomciopp
  • 2,602
  • 2
  • 31
  • 60
5
votes
2 answers

Jquery ajaxrequest xhr.status code 0 but html status code 200

This is not a cross site request problem as most googled answers to my questions consists of. I'm getting xhr.status 0 och xhr.statusText "error" when trying to make an ajax request with jquery functions .get and .load. In Firebug though, the…
moiran
  • 51
  • 1
  • 1
  • 5
5
votes
2 answers

What HTTP status to use for good request with "bad" input?

I'm writing a microservice for validating promo codes. The client sends me a promo code and a product ID (json). There is the 200 OK case where the code is good, I apply a discount for their order. But there is an error-ish case where the promo…
wim
  • 338,267
  • 99
  • 616
  • 750
5
votes
1 answer

Should this Json result return a 404 or 200?

I'm trying to make an API sorta loosly based on StackExchange's api results. So here's my json output. { "items" : [ ... objects in here .... ] "page" : "page_size" : "total_pages" : "total_items_count" : …
Pure.Krome
  • 84,693
  • 113
  • 396
  • 647
4
votes
4 answers

HTTP 200 (not 404) status for an empty list result returned from a REST endpoint

Please give me examples of official specification, or trusted recommendations that can prove my business partner that when they return an empty list from a REST endpoint, the HTTP status should be 200, not 404. For me RFC-2616 is obvious, but also…
4
votes
0 answers

.net core rc2 IIS7.5 returns blank page with Code 200

We have created a WepAPI with .NetCore RC2 including EntityFrameworkCore for access to our MSSQL Database. When publishing this WebAPI on the IIS on my localhost, it is working as expected. Now I tried to publish my WebAPI to one of our servers,…
4
votes
1 answer

Why XmlHttpRequest readyState = 2 on 200 HTTP response code

So I'm using plain javascript (no jquery), to send a file to the server. Server script PHP returns status code 200 at the end, but instead javascript is getting readyState == 2. The PHP code sends back status code 200: header('X-PHP-Response-Code:…
snowbound
  • 1,692
  • 2
  • 21
  • 29
3
votes
2 answers

Executing invoke-webrequest to get status of multple websites in Powershell

We have several websites and I don't want to check the status in powershell using invoke-webrequest -URI google.com every time. I drafted something like this, which isn't working and I'd like help with: $URLS = get-content…
3
votes
1 answer

Is checking for both readyState and status necessary in XMLHttpRequest?

In this discusison, we can see the syntax for handling XMLHttpRequest and guarding against a wrong readyState and status combinations as follows. if (request.readyState == 4 && request.status == 200) { ... } I've always been using the conjunctive…
user1672517
2
votes
0 answers

Status 200 (from disk cache) and 304 Not Modified issue

I'm using Next.js custom server, which by default sends strong ETag header on each page GET request. For each request I also manually add Cache-Control header res.setHeader('Cache-Control', 'public, max-age=${60 * 60}, s-maxage=${60 * 60 * 24},…
2
votes
1 answer

Rails default behavior: Why is Rails not generating different Etags by default or returning 304 Not Modified?

I am inspecting a Rails response. No http headers have been purposefully set to be returned from the server. The response includes Cache-Control: max-age=0, private, must-revalidate and Etag. The response is a 200 no matter how many times I make the…
2
votes
1 answer

Return http-status-code 200 or 204 if no content found to process

In web-API client made a get request with a parameter, to process something and get data from the file system. The parameter requested through the API a folder path. If API found that path, it is processing something on the resources inside and…
1
2 3 4 5