How do I get around this 400 bad request error?

Linode Staff

I`ve developed an Java Spring MVC application that runs 100% ok in my local server (with the same platform than Ubuntu : Apache Tomcat,, Java 9), but when I deploy this app to my Ubuntu server it always reject my requests that contain media Images (multiPart form). The message is:

400 bad request

I'm going to describe the step where the problem happens:

1) This is a Java Spring MVC application.

2) The data of the Image is sent from a html form like this:

<form action="uploadFile2.htm" method="post" enctype="multipart/form-data">
    Select File: <input type="file" name="newProb"/>
    <input type="submit" value="Upload File"/>
</form>

3) After the user select the pathname/name of the image file and press the submit button the info goes (by mean http) to the server side.

4) In the server side this info is received by a java controller (uploadFile2.htm) that translate all the info sent in the form, in java variables.

5) Then the program save the file in the path specified in the step 2 (not shown in this case).

The problem (Error 400) happens between the steps 3 and 4 , and happens with forms that have : enctype="multipart/form-data"
This kind of forms mean that contain media info.note

The other forms (that don't have this item) are working ok.

Please note that the problem happens before the program is treating to save the image (is not a permissions issue). Do you think that the site not being https is a culprit?

1 Reply

The 400 Bad Request error can happen for a few reasons, and while I'm no expert on what you're trying to do here I did do a little digging online and found an article from Stack Exchange that might help.

Getting '400 Bad Request' when using multipart/form-data as Content-Type in XHR Ask Question

I know the above isn't your exact situation, but the concept may be similar.

I hope that helps! Let us know what successes or failures you run into, and we'll be happy to keep working with you on this.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct