http-status-code-400

How to intentionally cause a 400 Bad Request in Python/Flask?

假装没事ソ 提交于 2019-12-19 02:37:49
问题 A consumer of my REST API says that on occasion I am returning a 400 Bad Request - The request sent by the client was syntactically incorrect. error. My application (Python/Flask) logs don't seem to be capturing this, and neither do my webserver/Nginx logs. Edit: I would like to try to cause a 400 bad request in Flask for debugging purposes. How can I do this? Following James advice, I added something similar to the following: @app.route('/badrequest400') def bad_request(): return abort(400)

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

好久不见. 提交于 2019-12-17 10:25:10
问题 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

WCF 400 Bad Request

风流意气都作罢 提交于 2019-12-12 12:30:38
问题 I created a simple function [OperationContract] [WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json)] string Start(); Definition, public String Start() { JavaScriptSerializer serializer = new JavaScriptSerializer(); return serializer.Serialize("Check"); } From browser using Javascript/Jquery, http://localhost/service1.svc tells me I have created a service and all other info.. Looks fine. I'm trying to call this using http://localhost/service1.svc/Start I get a 400 bad request

Android HTTP Post Request to IIS 7 Returns Bad Request(Invalid Header Name)

我的梦境 提交于 2019-12-12 05:48:10
问题 I have a MVC 3 Web Sevice being hosted on an Amazon EC2 Instance. I have an android app that is making a post request to the service. However a 400 bad request is returned saying that the header name is invalid. I checked the logs on the server and the request does not make it into IIS. The HTTP Err Log just has these entries: 2011-10-07 02:01:05 xxx.xxx.xx.xx xxxxx xx.xxx.xx.xx 80 HTTP/1.1 POST /API/UserAccount/Login 400 - Header - Not really sure what is going on. I tested this web service

Getting 400 bad request error in Jquery Ajax POST

跟風遠走 提交于 2019-12-12 03:25:54
问题 I am trying to send an Ajax POST request using Jquery but I am having 400 bad request error. Here is my code: $.ajax({ type: 'POST', url: "http://localhost:8080/project/server/rest/subjects", data: { "subject:title":"Test Name", "subject:description":"Creating test subject to check POST method API", "sub:tags": ["facebook:work", "facebook:likes"], "sampleSize" : 10, "values": ["science", "machine-learning"] }, error: function(e) { console.log(e); } }); It Says: Can not build resource from

GCM /topics/global works, but to register_id doesn't

穿精又带淫゛_ 提交于 2019-12-12 03:21:39
问题 I am working on a GCM project. Everything works when I use the parameter to send the message to all devices. However, I want the message to go to one specific device using the registration_id. As far as I can read in the documentation, I'm doing as I am supposed to do. When I use "to":"/topics/global" it works as seen below: JSONObject jGcmData = new JSONObject(); JSONObject jData = new JSONObject(); jData.put("message", customer.getToken()); jGcmData.put("to", "/topics/global"); jGcmData.put

MailGun Android HttpUrlConnection constant error 400

淺唱寂寞╮ 提交于 2019-12-12 01:25:22
问题 After a complete and utter failure to implement code with Retrofit, I have used Android's HttpURLConnection class to try and send an email through MailGun. However whatever I seem to do I get error 400 bad request back. I do not know what I am doing wrong - similar code seems to be working perfectly within iOS. The 4 lines commented out make no difference. Hardcoding the values for from and to did not fix it either. I have tried using application/json for Content-Type as well. Any pointers in

Why am I getting a 400: bad request?

。_饼干妹妹 提交于 2019-12-11 19:25:22
问题 I'm trying to post XML to my Tomcat server from an Android device, but I get zero bytes in the stream. I get a 400 bad request response, but I am not sure what's wrong with it. I can access my web application in a browser from Android and on my server's machine. When I log the XML, it looks fine. Why am I getting a 400: bad request? [ Update 4]: I just intercepted the request with Wireshark and get (Len=0) Length of zero. I still don't know why though. [ Update 3]: Posting to 10.0.2.2 crashes

Keycloak JavaScript Adapter receives 400 Bad Request in Internet Explorer

落花浮王杯 提交于 2019-12-11 15:21:11
问题 I'm using Keycloak's JavaScript Adapter to connect a web application with the SSO of my workplace. The code looks like this (server data is loaded via they keycloak.json file): const keycloak = Keycloak(); keycloak.init({onLoad: "login-required"}).success(authenticated => { ... }).error(() => { ... }); It works as intended on Firefox and Chrome, but on Internet Explorer (v. 11) the POST request for the token returns a 400 Bad Request. Is this a problem with my configuration of Internet

Custom error message with HTTPStatusCodeResult not working on localhost

一曲冷凌霜 提交于 2019-12-11 06:06:39
问题 I have a controller action that returns a 400 if validation fails: return new HttpStatusCodeResult(HttpStatusCode.BadRequest, "My custom message"); When running locally I get the standard "400 Bad Request", instead of the expected "400 My custom message". It works fine on the deployed site, and when running locally on my old PC . Could this be an IIS or Visual Studio configuration problem? I've tried diffing the applicationHost.config of my old and current computers but there was nothing