400 BAD request HTTP error code meaning?

前端 未结 8 1217
迷失自我
迷失自我 2020-11-22 03:38

I have a JSON request which I\'m posting to a HTTP URL.

Should this be treated as 400 where requestedResource field exists but \"Rom

8条回答
  •  鱼传尺愫
    2020-11-22 04:10

    Using 400 status codes for any other purpose than indicating that the request is malformed is just plain wrong.

    If the request payload contains a byte-sequence that could not be parsed as application/json (if the server expects that dataformat), the appropriate status code is 415:

    The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method.

    If the request payload is syntactically correct but semantically incorrect, the non-standard 422 response code may be used, or the standard 403 status code:

    The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated.

提交回复
热议问题