HTTP 400 Bad request 原因

My code is deployed in the Linux test environment, I am having problems using httpclient send http requests, requests 400 Bad request. Online are saying the following two reasons

HTTP status code is 400, there are two main forms:

  • 1, bad request means "bad request";
  • 2, invalid hostname meaning "domain name does not exist."

400 Bad Request is for obvious client error (e.g., malformed request syntax, the size is too large, invalid request message or fraudulent routing request), or the server does not process the request.

While ajax request more common background data. Generate  HTTP 400  wrong reasons are:

  • 1, the front end of the submitted data field name field type or entity class and background due to inconsistent package not; if necessary int, the client is transmitted String
  • 2, the front end of the data submitted to the background should be json string type, and the front end does not convert the object of type string;

solution:

  • 1, the control field name, type, ensure consistency

  • 2, using the tip stringify object passed into a string: namely  Data : the JSON . Stringify ( param );

Interface to take my first call, I just need to pass a parameter of type String, json do not need to type, so I do not meet my situation, my code is not above two problems, it looks like there are other the reason.

I walk a proxy. In the first to go when there is no debugging proxy, we did not encounter this problem. So from here to find the problem, finally solved the 400 error.

 

Guess you like

Origin www.cnblogs.com/ibigboy/p/11242776.html