How to fix 400 error in file uploading on flask server from android app
Flask throws a 400 Bad Request when it can't access a key in the request. My guess (just by looking at the code) is that you're trying to pull out request.files['filedata']
but it doesn't exist in the Java request.
However it does in the curl request -F filedata
.
Try taking a look at this: Http POST in Java (with file upload). It shows an example of how to add a part to your form upload using HttpClient and HttpPost.
According to this post you may need to add the encoding type of "multipart/form-data" as well.
tl;dr - Flask is looking for a filedata key in the request dict, you're not sending one.