In these two days, a simple and small requirement was developed iteratively. The post request received the parameters from the front end and converted the received JSON format into the corresponding POJO. However, the program reported the following exceptions in the process of receiving the request:
org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Invalid UTF-8 start byte 0xa0; nested exception is com.fasterxml.jackson.core.JsonParseException: Invalid UTF-8 start byte 0xa0 at [Source: java.io.PushbackInputStream@664c6a7d; line: 1, column: 61]
And because the front-end code has not been tested in the test environment, because it is tested using postman, 500 system abnormal error messages also appear in postman.
After a long time of searching on the Internet, I tried to set the content type attribute of the request response header, but it didn’t work and still reported an error;
After that, we also carefully checked whether there was a problem in the code, checked the @ requestbody annotation to receive JSON format data and convert it into the corresponding POJO, and the field properties are correct;
Finally, it is found in some blogs that it may also be the reason for Chinese spaces in JSON data, which is inspired.
After checking, use postman tool to select JSON strings with the same format, and the cursor will be displayed together. It is found that individual characters of Queshi do not correspond completely.
Check the corresponding sample
There is no exact correspondence
After modification
Test, success
In fact, it can also be seen from the error message that it is a JSON parsing error, which roughly means that it is an invalid Chinese byte at the beginning.
Read More:
- Error: required request body is missing, @ requestbody annotation usage
- HTTP 400 error – bad request
- The back end cannot receive the parameters passed by the front end
- Four ways to get Django parameters in request
- JSON parse e rror: Invalid UTF-8 middle byte 0x3f;
- ajax error 400 (Failed to load resource: the server responded with a status of 400 (Bad Request))
- 209151; org.json.JSONException A JSONObject text must begin with'{‘at character 1 of {
- java.lang.IllegalArgumentException : URI is not absolute error
- Python’s json.loads Invalid control character
- How to install postman tool in Ubuntu 16.04
- JSON parse error: invalid UTF-8 solution series
- Error: syntax error – unexpected token P in JSON at position 0
- egg.js The frame post request reported an error of invalid CSRF token security verification, which has been solved
- PHP big file upload problem (500m or above)
- Type error: the JSON object must be STR, bytes or byte array, not ‘textiowrapper’
- Required request body is missing with ContentCachingRequestWrapper
- Solution of error converting data type varchar to datetime in SQL Server
- Solution of Unicode decodeerror -‘utf-8 ‘codec can’t decode byte 0xc4 in position 0 – invalid continuation byte
- Wechat payment API V3 payment notice asynchronous signature verification failed
- “Invalid month” in SQL query