http-status-code-400

Django: 400 bad request syntax - what does this message mean?

那年仲夏 提交于 2019-11-28 21:00:50
I am using django to build a simple website. When you type the base address (which for now is 127.0.0.1:8000/ ), I use django to show a view which does some checks and redirects you based on your user privileges. (If you have admin privileges, you go to /admin , if you don't you go to /home , and if you aren't logged in you go to /login .) When I make that HTTP request, I get redirected as I should but I also see the following two errors in my django log: code 400, message Bad request syntax ('\x16\x03\x01\x00\x95\x01\x00\x00\x91\x03\x01N\xaa\x9c\x08\x96\x7f\x92\xe9Z\x925\xcaY4\xa6\xa5\xab\xf2

Server returned HTTP response code: 400

孤街醉人 提交于 2019-11-28 10:54:46
I am trying to get an InputStream from a URL. The URL can be a opened from Firefox. It returns a json and I have installed an addon for viewing json in Firefox so I can view it there. So I tried to get it from Java by: URL url = new URL(urlString); URLConnection urlConnection = url.openConnection(); BufferedReader reader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); But it is throwing an IOException in urlConnection.getInputStream(). I also tried: HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection(); InputStream inputStream = url

HttpURLConnection GET request getting 400 Bad Request

℡╲_俬逩灬. 提交于 2019-11-28 05:10:48
问题 I am trying to do a GET request with some parameters in Java using HttpURLConnection. Everytime I do this however, I get a 400: Bad Request each time. What do I need to change to make it work? String url = "http://www.awebsite.com/apath?p1=v1&p2=v2&p3=v3"; HttpURLConnection conn = (HttpURLConnection)new URL(url).openConnection(); conn.setDoInput(true); conn.setDoOutput(false); conn.setUseCaches(false); conn.setRequestMethod("GET"); conn.setRequestProperty("Host", "www.awebsite.com"); conn

Django: 400 bad request syntax - what does this message mean?

柔情痞子 提交于 2019-11-27 20:41:24
问题 I am using django to build a simple website. When you type the base address (which for now is 127.0.0.1:8000/ ), I use django to show a view which does some checks and redirects you based on your user privileges. (If you have admin privileges, you go to /admin , if you don't you go to /home , and if you aren't logged in you go to /login .) When I make that HTTP request, I get redirected as I should but I also see the following two errors in my django log: code 400, message Bad request syntax

How to customize @RequestParam error 400 response in Spring MVC

≡放荡痞女 提交于 2019-11-27 17:49:49
问题 Is there a way to customize what gets displayed when a required @RequestParam is not sent to the request handler? I always get HTTP Status 400 with a description " The request sent by the client was syntactically incorrect (). " in this case. 回答1: Yes, there is a way you should catch MissingServletRequestParameterException You can do it in several ways: 1) @ExceptionHandler(MissingServletRequestParameterException.class) public String handleMyException(Exception exception) { return

RESTful API - Correct behaviour when spurious/not requested parameters are passed in the request

三世轮回 提交于 2019-11-27 12:57:56
问题 We are developing a RESTful api that accepts query parameters in the request in the form of JSON encoded data. We were wondering what is the correct behaviour when non requested/not expected parameters are passed along with the required ones. For example, we may require that a PUT request on a given endpoint have to provide exactly two values respectively for the keys name and surname : { "name": "Jeff", "surname": "Atwood" } What if a spurious key is passed too, like color in the example

HTTP 400 (bad request) for logical error, not malformed request syntax

非 Y 不嫁゛ 提交于 2019-11-27 11:00:37
The HTTP/1.1 specification (RFC 2616) has the following to say on the meaning of status code 400, Bad Request (§10.4.1) : The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications. There seems to be a general practice among a few HTTP-based APIs these days to use 400 to mean a logical rather than a syntax error with a request. My guess is that APIs are doing this to distinguish between 400 (client-induced) and 500 (server-induced). Is it acceptable or incorrect to use 400 to indicate non-syntactic errors? If it is

Returning http 200 OK with error within response body

白昼怎懂夜的黑 提交于 2019-11-27 03:57:49
问题 I'm wondering if it is correct to return HTTP 200 OK when error on server side occurred with some error inside of response body. Example: We're sending http GET Something unexpected happened on the server side. Server returns http 200 OK status code with error inside a response (e.g. {"status":"some error occured"} Is is correct behavior or not? Shouldn't we change status code? 回答1: No, this is very incorrect. HTTP is an application protocol. 200 implies that the response contains a payload

Server returned HTTP response code: 400

时间秒杀一切 提交于 2019-11-27 03:52:12
问题 I am trying to get an InputStream from a URL. The URL can be a opened from Firefox. It returns a json and I have installed an addon for viewing json in Firefox so I can view it there. So I tried to get it from Java by: URL url = new URL(urlString); URLConnection urlConnection = url.openConnection(); BufferedReader reader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); But it is throwing an IOException in urlConnection.getInputStream(). I also tried:

How to send Request payload to REST API in java?

丶灬走出姿态 提交于 2019-11-27 01:01:01
I want to retrieve the JSON data from the following: https://git.eclipse.org/r/#/c/11376/ Request URL: https://git.eclipse.org/r/gerrit/rpc/ChangeDetailService Request Method: POST Request Headers: Accept:application/json Content-Type:application/json; charset=UTF-8 Request Payload: {"jsonrpc":"2.0","method":"changeDetail","params":[{"id":11376}],"id":1} I already tried this answer but I am getting 400 BAD REQUEST . Can anyone help me sort this out? Thanks. Gangaraju The following code works for me. //escape the double quotes in json string String payload="{\"jsonrpc\":\"2.0\",\"method\":\