400 is an HTTP status code, mainly in two forms:

  • 1. "bad request" means "invalid request";
  • 2. "invalid hostname" means "nonexistent domain name".

400 Bad Request is due to an obvious client error (e.g., malformed request syntax, too large size, invalid request message, or deceptive routing request), and the server cannot or will not process the request.

It is quite common when requesting backend data via AJAX. The causesHTTP 400of the error are:

  • 1. The field names or field types of the data submitted by the frontend are inconsistent with the backend entity class, making it impossible to bind;
  • 2. The data submitted by the frontend to the backend should be a JSON string type, but the frontend did not convert the object to a string type;

Solutions:

  • 1. Check the field names and ensure consistency of types

  • 2. Use stringify to convert the object passed by the frontend into a string:

    data: JSON.stringify(param);

For more content, you can view:

HTTP Status Codes

JSON.stringify()