Questions tagged [http-status-code-400]

400 Bad Request. Add this tag to a question if your requests receive this answer.

The request could not be understood by the server due to malformed syntax. The client should not repeat the request without modifications.

See also RFC2616.

806 questions
379
votes
10 answers

400 BAD request HTTP error code meaning?

I have a JSON request which I'm posting to a HTTP URL. Should this be treated as 400 where requestedResource field exists but "Roman" is an invalid value for this field? [{requestedResource:"Roman"}] Should this be treated as 400 where "blah"…
Phoenix
  • 8,695
  • 16
  • 55
  • 88
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
68
votes
6 answers

What are the possible reasons to get APNs responses BadDeviceToken or Unregistered?

When sending notifications to iOS users, for some of them I get response status code 400 (BadDeviceToken) or code 410 (Unregistered). From Apple documentation about "BadDeviceToken": The specified device token was bad. Verify that the request…
64
votes
8 answers

HTTP 400 (bad request) for logical error, not malformed request syntax

The HTTP/1.1 specification (RFC 2616) has the following to say on the meaning of status code 400, Bad Request (§10.4.1): The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request…
Atif Aziz
  • 36,108
  • 16
  • 64
  • 74
63
votes
6 answers

Getting 400 bad request error in Jquery Ajax POST

I am trying to send an Ajax POST request using Jquery but I am having 400 bad request error. Here is my code: $.ajax({ type: 'POST', url: "http://localhost:8080/project/server/rest/subjects", data: { "subject:title":"Test Name", …
Sachin Jain
  • 21,353
  • 33
  • 103
  • 168
61
votes
1 answer

What is the most appropriate HTTP status code to return if a required header is missing?

I read What HTTP status response code should I use if the request is missing a required parameter? but it did not specifically ask about headers and there didn't seem to be a consensus. The context of this question assumes successful authentication.…
58
votes
3 answers

Django: 400 bad request syntax - what does this message mean?

I am using django to build a simple website. When you type the base address (which for now is 127.0.0.1:8000/), I use django to show a view which does some checks and redirects you based on your user privileges. (If you have admin privileges, you go…
Miriam
  • 969
  • 1
  • 6
  • 15
33
votes
0 answers

Sec-Fetch-Mode and blocked CORS

So I have the same website making the same request to the same server on (1) Chrome 76 and (2) Chrome 77 from different networks and computers. One request has (1) Sec-Fetch-Mode: no-cors, Sec-Fetch-Site: cross-site and the other one (2)…
33
votes
3 answers

Http Status Code 400 vs 412

So I'm developing a Rest API When a POST is made to create a resource and a required field is missing what should I return? 400 - Bad Request OR 412 - Precondition Failed And Why?
adamclerk
  • 759
  • 1
  • 6
  • 15
30
votes
6 answers

RESTful API - Correct behaviour when spurious/not requested parameters are passed in the request

We are developing a RESTful api that accepts query parameters in the request in the form of JSON encoded data. We were wondering what is the correct behaviour when non requested/not expected parameters are passed along with the required ones. For…
Paolo
  • 15,233
  • 27
  • 70
  • 91
30
votes
2 answers

REST - When to use 400 ("Bad Request")

I have a resource like this sales/customers/{customerno}. If a client sends a PUT request to this resource I would return 400 - Bad request if the xml in the entity body is not valid xml. But what if the xml is valid, but the content of the xml is…
29
votes
2 answers

How to send Request payload to REST API in java?

I want to retrieve the JSON data from the following: https://git.eclipse.org/r/#/c/11376/ Request URL: https://git.eclipse.org/r/gerrit/rpc/ChangeDetailService Request Method: POST Request…
Gangaraju
  • 4,406
  • 9
  • 45
  • 77
23
votes
1 answer

400 vs 422 for Client Error Request

I've read a lot of posts and articles regarding proper http status code to return for client request error. Others suggest to use 400 as it has been redefined in RFC 7231 though I'm not sure if the example given covers all the client error in my…
21
votes
4 answers

How to intentionally cause a 400 Bad Request in Python/Flask?

A consumer of my REST API says that on occasion I am returning a 400 Bad Request - The request sent by the client was syntactically incorrect. error. My application (Python/Flask) logs don't seem to be capturing this, and neither do my…
Matthew Moisen
  • 16,701
  • 27
  • 128
  • 231
19
votes
2 answers

HTTP 404 vs 400 for invalid query parameters

Here is my request URL: http://server.com/app/user/getuser/?userId=9999 Note that userId is query parameter. Not embedded path parameter. I understand that if the request URL is: http://server.com/app/user/getuser/9999 and the ID 9999 does not exist…
LHA
  • 9,398
  • 8
  • 46
  • 85
1
2 3
53 54