I'm building a simple http server in nodejs that validates the outgoing json. If the validation fails, what would be the correct status code / error message to send to the client?
What http status should I send for a malformed json response?
886 views Asked by brielov At
2
There are 2 answers
0
reivaj96
On
The common status codes are:
4xx means client errors
- 400 bad request
- 401 unauthorized
- 403 Forbidden
- 404 Not found
- 405 method not allowed
2xx means HTTP code status
- 200 OKs, this is for the update or get resource successfully
- 201, means that any source was created
- 204, means that request doest have a useful load, but we have used it when are updating
5xx means server errors
- 500 Internal server error
- 501 Not implemented
- 502 bad gateway
- 503 services unavailable
There are more. But these are perhaps the most common
Related Questions in NODE.JS
- Using Puppeteer to scrape a public API only when the data changes
- How to request administrator rights?
- How do I link two models in mongoose?
- Variable inside a Variable, not updating
- Unable to Post Form Data to MongoDB because of picturepath
- Connection terminated unexpectedly while performing multi row insert using pg-promise
- Processing multiple forms in nodejs and postgresql
- Node.js Server + Socket.IO + Android Mobile Applicatoin XHR Polling Error...?
- How to change the Font Weight of a SelectValue component in React when a SelectItem is selected?
- My unban and ban commands arent showing when i put the slash
- how to make read only file/directory in Mac writable
- How can I outsource worker processes within a for loop?
- Get remote MKV file metadata using nodejs
- Adding google-profanity-words to web page
- Products aren't displayed after fetching data from mysql db (node.js & express)
Related Questions in HTTP
- Handling both JSON and form values in POST request body with unknown values in Golang
- Why can't I use PUT requests?
- nginx set up reverse proxy from subfolder to a port
- Async Web Server RP2040 returning ERR_CONNECTION_REFUSED?
- Getting `FormatException: Missing extension byte (at offset 6)` exception for accessing `response.body` from a server deployed in Vercel
- Retrieving list of values from MYSQL data base based on input value(LARAVEL 10 )(GET HTTP METHOD)
- Unable to add request headers via CHttpFile - C++/MFC
- Why do we call all http services 'Web Api/Web Service'?
- How to correctly read POST REQUEST body on ESP32?
- on linux gitclone issue remote server error showing fatal error with proxy n port
- Elasticsearch - cascading http inputs from Airflow API
- How to clean the html pages opened in a session?
- UTF-8 is not a valid encoding name
- I dont get the Result i expected when i want to get my Telegram Chatbot id
- NextJS 14 SSE with TransformStream() sending messages in a single response
Related Questions in JSONSCHEMA
- Getting error as `schema with key or id "https://json-schema.org/draft/2020-12/schema" already exists when performing schema Validation using ajv?
- Need to know the difference between contains and items keyword of json schema validation
- pydantic model with fields that have dependent allowable values
- Validate property value based on the value of another property in JSON schema
- How to get/read the summary text from class definition
- JSON SCHEMA Nested Array Fields Validation based on Root level Field
- Few enums have constants values in common, causing OpenAPI Generator to fail. How to put some of the model classes, types in different packages?
- Extract properties from JSON Schema inside allOf
- Generate FastAPI docs from msgspec.Struct json schema
- Java - JSON schema validation does NOT fail when array elements do not follow pattern
- JSON Schema with array of different object types with mandatory property fails to validate
- Is there any npm package that can show json schema in table?
- JSON Schema Validator passes despite issues
- AJV ignores 'required' rule for properties in nested, referenced object
- Need Detailed Error in json schema validation Python
Related Questions in HTTP-STATUS
- how to return only HTTP Status code, if we hit one pre-defined endpoint
- Check IMG URL status (PHP get_headers)
- Which HTTP status should I return if the client tries to upload a new file while server is still processing the previous one?
- Which is the proper response code for this scenario - 207 vs 400 status code
- Correct http status for invalid config in request body?
- HTTP status code for an expired confirmation code
- NestJS - Cannot set headers after they are sent to the client
- My TeaMaster9001 is responding with code 418 whenever I send a brew-coffee request
- REST API response status code - search GET that returns a single result
- What http status should I send for a malformed json response?
- HTTP status quote when a resource can't be inserted but could be fixed by the client
- How to force Spring Boot to set correct HTTP status code to error response?
- Is there any possibility to get status code i.e. (200,301,302) after loading html page in CefSharp C#?
- Detecting 413 (or other HTTP Status) in PHP
- How do I force Nancy to use application/json Response for Integers? Nancy assumes them to be StatusCode
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Since the error occurs on the server, the error should be in the 500s.
There doesn't appear to be any error message corresponding to this problem in particular, so you can use the generic one indicating that there was some problem on the server: Error 500 Internal Server Error. Logic performed on the server failed to fulfill expectations.