http-status-code-400

REST - When to use 400 (“Bad Request”)

点点圈 提交于 2019-12-06 16:43:07
问题 I have a resource like this sales/customers/{customerno}. If a client sends a PUT request to this resource I would return 400 - Bad request if the xml in the entity body is not valid xml. But what if the xml is valid, but the content of the xml is not valid. Say for instance that the client is trying to update the customers PostCode and is providing a PostCode which is not valid. Is it correct to return 400 - Bad request in this case, or is it another http code I should have used? 回答1: From

Content type for file part of the multipart/form-data request is set wrong by the client

谁说胖子不能爱 提交于 2019-12-06 02:56:16
I'm trying to send multipart/form-data with following JavaScript and jQuery: var formData = new FormData(); formData.append("projectName", $("#projectNameInput").val()); var file = $("#fileInput")[0].files[0]; formData.append("content", file); var xhr = new XMLHttpRequest(); xhr.open('POST', '/project', true); xhr.onload = function(ev) { // Handling logic omitted }; xhr.send(formData); However, some client browsers (Firefox and Chrome) receive 400 Bad Request from the server. While examining the headers and request payload I discovered that some browsers set explicit content type for the file

400 status error when posting form data in ASP.Net Core [closed]

一世执手 提交于 2019-12-05 05:21:42
I am developing an ASP.Net Core 2.0 application and run it on Linux/Nginx/Kestrel. On the development environment (Windows 10) everything runs smoothly. Also when running the app with "dotnet run" in the project directory. On the production environment (Debian 8/Kestrel) all form POSTs fail with HTTP status code 400 (Bad Request) without prompting any error in the console, while form GET requests run fine. All other messages (warnings, errors) are prompted in the console. I am running the application using "dotnet .dll". Can anyone point me into a direction to solve the issue? 来源: https:/

REST - When to use 400 (“Bad Request”)

橙三吉。 提交于 2019-12-04 22:20:59
I have a resource like this sales/customers/{customerno}. If a client sends a PUT request to this resource I would return 400 - Bad request if the xml in the entity body is not valid xml. But what if the xml is valid, but the content of the xml is not valid. Say for instance that the client is trying to update the customers PostCode and is providing a PostCode which is not valid. Is it correct to return 400 - Bad request in this case, or is it another http code I should have used? From Wikipedia's List of HTTP Status Codes : 400 Bad Request: The request cannot be fulfilled due to bad syntax.

What is the proper configuration for a WCF 4 REST service?

让人想犯罪 __ 提交于 2019-12-04 04:29:58
问题 Sorry to post about this, but it's driving me nuts. I am using routes in the WCF4 REST template in VS2010. I set the maxreceivedmessagesize property to some gargantuan number, and it still gives me an HTTP status code 400 when I try to submit xml to the service. I turned on tracing, and the message tells me that it's still set to the default message size. This makes me think that the problem is some nuance in how I have my web.config set up. Could somebody take a quick peak at it and let me

Spring form ModelAttribute field validation to avoid 400 Bad Request Error

巧了我就是萌 提交于 2019-12-03 14:42:23
I've got an ArticleFormModel containing data sent by normal html form which is injected by Spring using @ModelAttribute annotation, i.e. @RequestMapping(value="edit", method=RequestMethod.POST) public ModelAndView acceptEdit(@ModelAttribute ArticleFormModel model, HttpServletRequest request, BindingResult errors) { //irrelevant stuff } Everything works perfectly fine up to some point. The problem is that the ArticleFormModel contains a double field ( protected , set using normal setter). Everything works fine as long as data sent by user is a number. When they type a word, all I get is 400 Bad

Redirect with POST parameters in MVC 4 for Payment Gateway Integration

十年热恋 提交于 2019-12-01 21:39:50
I am trying to do a payment gateway integration using mvc4 in razor. In that i need to call a page with prefilled post form. Using the below method, I am forming the post method form: private static string PreparePOSTForm(string url, System.Collections.Hashtable data) // post form { //Set a name for the form string formID = "PostForm"; //Build the form using the specified data to be posted. StringBuilder strForm = new StringBuilder(); strForm.Append("<form id=\"" + formID + "\" name=\"" + formID + "\" action=\"" + url + "\" method=\"POST\">"); foreach (System.Collections.DictionaryEntry key in

What is the proper configuration for a WCF 4 REST service?

耗尽温柔 提交于 2019-12-01 20:48:07
Sorry to post about this, but it's driving me nuts. I am using routes in the WCF4 REST template in VS2010. I set the maxreceivedmessagesize property to some gargantuan number, and it still gives me an HTTP status code 400 when I try to submit xml to the service. I turned on tracing, and the message tells me that it's still set to the default message size. This makes me think that the problem is some nuance in how I have my web.config set up. Could somebody take a quick peak at it and let me know what they think? I've been around and around with this, and an extra set of eyes would be of great

Mobiledevices: action missing

徘徊边缘 提交于 2019-12-01 14:55:42
I am trying to perform a POST of the action, however, when I make the request I get code 400 speaking that the action value is missing. my code: function mobileAPIPOST() { var response = UrlFetchApp.fetch( "https://www.googleapis.com/admin/directory/v1/customer/my_customer/devices/mobile/fakexQ_fake0Z0dKFdSblfakeTnnfakel7IYwixfake4ddZfakeAIvnmu/action", { method: "POST", headers: { "Authorization": "Bearer " + ScriptApp.getOAuthToken(), "Content-Type": "application/json", }, data: { "action": "block" }, muteHttpExceptions: true }); } I updated the code following the response from @TheMaster.

Mobiledevices: action missing

南楼画角 提交于 2019-12-01 13:09:16
问题 I am trying to perform a POST of the action, however, when I make the request I get code 400 speaking that the action value is missing. my code: function mobileAPIPOST() { var response = UrlFetchApp.fetch( "https://www.googleapis.com/admin/directory/v1/customer/my_customer/devices/mobile/fakexQ_fake0Z0dKFdSblfakeTnnfakel7IYwixfake4ddZfakeAIvnmu/action", { method: "POST", headers: { "Authorization": "Bearer " + ScriptApp.getOAuthToken(), "Content-Type": "application/json", }, data: { "action":